public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Customized DokuWiki's Interwiki links
@ 2020-12-03 10:55 Denis Bitouzé
       [not found] ` <878safcg6x.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Bitouzé @ 2020-12-03 10:55 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Hi,

DokuWiki's defines default Interwiki links, e.g.:

    `[[wp>InterWiki]]`

that will result in a DokuWiki site into a link with:

-   text: "InterWiki"
- target: https://en.wikipedia.org/wiki/InterWiki

Fortunately, pandoc is aware of them:

  ┌────
  │ https://hackage.haskell.org/package/pandoc-2.11.2/docs/src/Text.Pandoc.Readers.DokuWiki.html#splitInterwiki
  └────

But DokuWiki lets the user define his own Interwiki links e.g., with the
following in some config file:

    `faquk     https://texfaq.org/{URL}`

the code :

    `[[faquk>FAQ-mathml|Math on the Web]]`

will result in a DokuWiki site into a link with:

-   text: "Math on the Web"
- target: https://texfaq.org/FAQ-mathml

Currently, such a customized link is considered by pandoc as a not
Interwiki link and would result into a link with:

-   text: "Math on the Web"
- target: https://www.google.com/search?q=a4&btnI=lucky

I guess extending the handling of such DokuWiki's Interwiki links
shouldn't be made at a Haskell level but as a (Lua) filter.

Do you see an easy way to achieve this (Lua filters are still a pain for
me)?

Thanks!
-- 
Denis

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/878safcg6x.fsf%40example.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Customized DokuWiki's Interwiki links
       [not found] ` <878safcg6x.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
@ 2020-12-03 19:37   ` John MacFarlane
       [not found]     ` <m2sg8mof4j.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2020-12-03 19:37 UTC (permalink / raw)
  To: Denis Bitouzé, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw


>    `[[faquk>FAQ-mathml|Math on the Web]]`

Yes, we have no way in pandoc to parse the asciidoc
config file.  I suppose we could parse it as a link
with destination "FAQ-mathml", text "Math on the Web",
and a special attribute `interwiki="faquk"`.
A lua filter could then check this attribute.

But I'm not sure that gives you any more real
power than the current system; you can use a
filter to check the link for a faquk> prefix
and modify it accordingly.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Customized DokuWiki's Interwiki links
       [not found]     ` <m2sg8mof4j.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-12-04 20:16       ` Denis Bitouzé
       [not found]         ` <87h7p1xr60.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Bitouzé @ 2020-12-04 20:16 UTC (permalink / raw)
  To: John MacFarlane; +Cc: Denis Bitouzé, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Le 03/12/20 à 11h37, John MacFarlane a écrit :

>>    `[[faquk>FAQ-mathml|Math on the Web]]`
>
> Yes, we have no way in pandoc to parse the asciidoc
> config file.  I suppose we could parse it as a link
> with destination "FAQ-mathml", text "Math on the Web",
> and a special attribute `interwiki="faquk"`.
> A lua filter could then check this attribute.
>
> But I'm not sure that gives you any more real
> power than the current system; you can use a
> filter to check the link for a faquk> prefix
> and modify it accordingly.

Unfortunately, the prefix is lost while processing `pandoc`:

--8<---------------cut here---------------start------------->8---
$ echo -e "[[faquk>FAQ-mathml|Math on the Web]]" | pandoc -f dokuwiki -t native
--8<---------------cut here---------------end--------------->8---

returns:

  ┌────
  │ [Para [Link ("",[],[]) [Str "Math",Space,Str "on",Space,Str "the",Space,Str "Web"] ("https://www.google.com/search?q=FAQ-mathml&btnI=lucky","")]]
  └────

where `faquk` is missing.
-- 
Denis

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87h7p1xr60.fsf%40example.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Customized DokuWiki's Interwiki links
       [not found]         ` <87h7p1xr60.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
@ 2020-12-04 22:51           ` John MacFarlane
       [not found]             ` <m21rg5mbg8.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: John MacFarlane @ 2020-12-04 22:51 UTC (permalink / raw)
  To: Denis Bitouzé
  Cc: Denis Bitouzé, pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw



Denis Bitouzé <denis.bitouze-PToOLB6qFnLddoiwg0DPyg@public.gmane.org> writes:

> Le 03/12/20 à 11h37, John MacFarlane a écrit :
>
>>>    `[[faquk>FAQ-mathml|Math on the Web]]`
>>
>> Yes, we have no way in pandoc to parse the asciidoc
>> config file.  I suppose we could parse it as a link
>> with destination "FAQ-mathml", text "Math on the Web",
>> and a special attribute `interwiki="faquk"`.
>> A lua filter could then check this attribute.
>>
>> But I'm not sure that gives you any more real
>> power than the current system; you can use a
>> filter to check the link for a faquk> prefix
>> and modify it accordingly.
>
> Unfortunately, the prefix is lost while processing `pandoc`:

Ah, I see. Well, then a code change would be needed for this.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m21rg5mbg8.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Customized DokuWiki's Interwiki links
       [not found]             ` <m21rg5mbg8.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-12-05 10:36               ` Denis Bitouzé
       [not found]                 ` <874kl0y1xo.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Bitouzé @ 2020-12-05 10:36 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Le 04/12/20 à 14h51, John MacFarlane a écrit :

>> Unfortunately, the prefix is lost while processing `pandoc`:
>
> Ah, I see. Well, then a code change would be needed for this.

OK.

I don't want to put extra pressure on anybody :) but do you plan to do
this change and, if so, at what time scale?

Of course, I would understand an answer such as: "Releases come when
they come!". But I'm asking because I'm a bit in a hurry so, in such
a case, I would preprocess the DokuWiki files, e.g. replacing (with
e.g. `sed`) strings such as:

  ┌────
  │ [[faquk>FAQ-mathml|Math on the Web]]
  └────

by:

  ┌────
  │ [faquk>FAQ-mathml|Math on the Web]
  └────

in order Pandoc doesn't consider them as links but just as strings and
use a Lua filter in order Pandoc export them as required by
reStructuredText.
-- 
Denis

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/874kl0y1xo.fsf%40example.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Customized DokuWiki's Interwiki links
       [not found]                 ` <874kl0y1xo.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
@ 2020-12-05 15:33                   ` Denis Bitouzé
  0 siblings, 0 replies; 6+ messages in thread
From: Denis Bitouzé @ 2020-12-05 15:33 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

Le 05/12/20 à 11h36, Denis Bitouzé a écrit :

> Le 04/12/20 à 14h51, John MacFarlane a écrit :
>
>>> Unfortunately, the prefix is lost while processing `pandoc`:
>>
>> Ah, I see. Well, then a code change would be needed for this.
>
> OK.
>
> I don't want to put extra pressure on anybody :) but do you plan to do
> this change and, if so, at what time scale?
>
> Of course, I would understand an answer such as: "Releases come when
> they come!". But I'm asking because I'm a bit in a hurry so, in such
> a case, I would preprocess the DokuWiki files, e.g. replacing (with
> e.g. `sed`) strings such as:
>
>   ┌────
>   │ [[faquk>FAQ-mathml|Math on the Web]]
>   └────
>
> by:
>
>   ┌────
>   │ [faquk>FAQ-mathml|Math on the Web]
>   └────
>
> in order Pandoc doesn't consider them as links but just as strings and
> use a Lua filter in order Pandoc export them as required by
> reStructuredText.

Well, not that easy: suppose I replace `[[` and `]]`, not by `[` and `]`
(stupid idea: would be confusing), but by something really special,
say `µµ` and `§§`.

In such a case, it's easy with a Lua to replace something like:

  ┌────
  │ µµprefix>urlComplement|text§§
  └────

into:

  ┌────
  │ :prefix:`text <urlComplement>`
  └────

or, depending on the case:

  ┌────
  │ :prefix:`urlComplement`
  └────

Here is a test case:

--8<---------------cut here---------------start------------->8---
function shortLink (link)
   local prefix
   local urlComplement
   local text
   local sLink
   if string.match(link, "|") then
      prefix, urlComplement, text = string.match(link, "(%a+)>(%g+)|(.+)§§")
   else
      prefix, urlComplement    = string.match(link, "(%a+)>(%g+)§§")
   end
   if text and urlComplement ~= text then
      sLink = ":" .. prefix .. ":`" .. text .. " <" .. urlComplement .. ">`"
   else
      sLink = ":" .. prefix .. ":`" .. urlComplement .. "`"
   end
   -- return sLink
   print(sLink)
end

link = "µµfaquk>FAQ-mathml|Math on the Web§§"
shortLink (link)

link = "µµctanpkg>html|html§§"
shortLink (link)

link = "µµctanpkg>rtf2tex§§"
shortLink (link)
--8<---------------cut here---------------end--------------->8---

Unfortunately ;), Pandoc preprocess such strings into:

  ┌────
  │ [Para [Str "\181\181faquk>FAQ-mathml|Math",Space,Str "on",Space,Str "the",Space,Str "Web\167\167"]
  │ ,Para [Str "\181\181ctanpkg>html|html\167\167"]
  │ ,Para [Str "\181\181ctanpkg>rtf2tex\167\167"]]
  └────

Much less handy :$
--
Denis

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/87tut0w9m7.fsf%40example.com.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-05 15:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 10:55 Customized DokuWiki's Interwiki links Denis Bitouzé
     [not found] ` <878safcg6x.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-03 19:37   ` John MacFarlane
     [not found]     ` <m2sg8mof4j.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-12-04 20:16       ` Denis Bitouzé
     [not found]         ` <87h7p1xr60.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-04 22:51           ` John MacFarlane
     [not found]             ` <m21rg5mbg8.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-12-05 10:36               ` Denis Bitouzé
     [not found]                 ` <874kl0y1xo.fsf-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org>
2020-12-05 15:33                   ` Denis Bitouzé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).