Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dokuwiki math support [enhancement] #5319

Open
bachmeil opened this issue Feb 19, 2019 · 2 comments
Open

Dokuwiki math support [enhancement] #5319

bachmeil opened this issue Feb 19, 2019 · 2 comments

Comments

@bachmeil
Copy link

Conversion from Dokuwiki doesn't support math. The standard way to add math to a Dokuwiki page is with the MathJax plugin, and the syntax is the same as markdown. This currently fails:

$$y_{i} = \varepsilon_{i}$$

with message

Error at "source" (line 5, column 5):
unexpected "i"
expecting "{{"
$$y_{i} = \varepsilon_{i}$$
    ^

The error message says expecting "{{" but that's because it's trying to link to an image. That doesn't help with math.

@RyanGreenup
Copy link

RyanGreenup commented Sep 2, 2020

Yeah I just ran into this, I tried:

pandoc -f dokuwiki+tex_math_double_dollars -t latex 

and it returns an error saying that there is no support.

I would love to see this implemented because dokuwiki is very common and as opposed to mediawiki does not require a database making it more portable.

A workaround that I hope continues to work is to do this:

pandoc input.txt -f dokuwiki -t org | pandoc -f org -t pdf -o file.pdf

This isn't too bad because org-mode supports a tonne of markup and so should handle most things fairly well.


Edit:

A more reliable solution would be to use the Dokuwiki Parser out of the gate, this will only work if the MathJax Extension is installed, assuming that Dokuwiki is installed in /srv/http/dokuwiki, take some exemplar file.dw and convert it like so:

sudo \
/srv/http/dokuwiki/bin/render.php  < file.dw |\
pandoc -f html+raw_tex+tex_math_dollars+tex_math_single_backslash -t latex |\
pandoc -f latex -t html --mathjax -s -o /tmp/file.html
xdg-open file.html & disown

the output should have all the math working as would be expected

Output
Source Output
file.dw
This is some text

====== H1 ======

===== H2 =====

==== H3 ====

=== H4 ===

== H5 ==

  • H6 should become a bullet item

====== What Should Work ======

===== LaTeX AMSmath Align =====

I don't know what a raw block is

\begin{align}
8 &= 8x^2+ 4x + 3 \
0 &= 8x^2 + 4x - 5 \
x &= \frac{- b \pm \sqrt{b^2- 4\times 8\times \left( - 5 \right) } }{2\times 8}
\end{align}

====== What could appear ======

===== KaTeX Aligned =====

$$\begin{aligned}
8 &= 8x^2+ 4x + 3 \
0 &= 8x^2 + 4x - 5 \
x &= \frac{- b \pm \sqrt{b^2- 4\times 8\times \left( - 5 \right) } }{2\times 8}
\end{aligned}$$

===== Dollars Align =====
This isn't valid LaTeX but works in MathJax and should be interpreted.

$$
\begin{align}
8 &= 8x^2+ 4x + 3 \
0 &= 8x^2 + 4x - 5 \
x &= \frac{- b \pm \sqrt{b^2- 4\times 8\times \left( - 5 \right) } }{2\times 8}
\end{align}
$$

===== Backslash Align =====
This isn't valid LaTeX but works in MathJax and should be interpreted.
[
\begin{align}
8 &= 8x^2+ 4x + 3 \
0 &= 8x^2 + 4x - 5 \
x &= \frac{- b \pm \sqrt{b^2- 4\times 8\times \left( - 5 \right) } }{2\times 8}
\end{align}
]

@RyanGreenup
Copy link

To go in the other direction from org-mode to dokuwiki without losing raw LaTeX this filter could be used:

#!/usr/bin/env python

"""
Pandoc filter to convert raw tex to paragraph for dokuwiki
"""

from pandocfilters import toJSONFilter, Emph, Para

def raw_to_para(key, value, format, meta):
  if key == 'RawBlock' and value[0] == 'latex':
    math_content = value[1]
    math_value=[{
            "t": "Str",
            "c": math_content
                }]

    return Para(math_value)

if __name__ == "__main__":
  toJSONFilter(raw_to_para)

so save that in filter.py and then run:

chmod +x filter.py
pip install pandocfilters
pandoc file.txt -f dokuwiki -t org --filter ./filter.py 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants