问题
I am converting a markdown file into mediawiki table using pandoc:
content of file mtcars.md
:
| |c1 |c2 |
|:--|:----|:--|
|7 |P$A |A |
|8 |AB |B |
|9 |P$A |C |
Then I do (I am using Ubuntu 64 bits and pandoc version 1.13.2)
pandoc -t mediawiki -o mtcars.txt mtcars.md
But the two $
signs are interpreted as <math>...</math>
:
{|
!
!c1
!c2
|-
|7
|P<math>A |A | |8 |AB |B | |9 |P</math>A
|C
|}
How can I get the dollar signs instead?
回答1:
The pandoc documentation says:
Anything between two $ characters will be treated as TeX math. The opening $ must have a non-space character immediately to its right, while the closing $ must have a non-space character immediately to its left, and must not be followed immediately by a digit. Thus, $20,000 and $30,000 won’t parse as math. If for some reason you need to enclose text in literal $ characters, backslash-escape them and they won’t be treated as math delimiters.
So, one way is to put a backslash in front of the $:
| |c1 |c2 |
|:--|:----|:--|
|7 |P\$A |A |
|8 |AB |B |
|9 |P\$A |C |
Output:
| |c1 |c2 | |:--|:----|:--| |7 |P$A |A | |8 |AB |B | |9 |P$A |C |
(I don't seem to get the same mediawiki output formatting as you, but you get the point).
Another way is to put a space after the $, although that adds a space in the output.
The interpretation of the $ signs are part of a markdown extension called tex_math_dollars
- you should be able to suppress that altogether by specifying an input format of markdown-tex_math_dollars
or markdown_strict
(although that did not work on the older version of pandoc that I have here).
来源:https://stackoverflow.com/questions/29553312/prevent-pandoc-from-converting-into-mediawiki-math