防止pandoc将$转换为mediawiki< math> [英] prevent pandoc from converting $ into mediawiki <math>

查看:112
本文介绍了防止pandoc将$转换为mediawiki< math>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pandoc将markdown文件转换为mediawiki表:

I am converting a markdown file into mediawiki table using pandoc:

文件mtcars.md的内容:

|   |c1   |c2 |
|:--|:----|:--|
|7  |P$A |A  |
|8  |AB  |B  |
|9  |P$A |C  |

然后我做(我正在使用Ubuntu 64位和pandoc版本1.13.2)

Then I do (I am using Ubuntu 64 bits and pandoc version 1.13.2)

pandoc -t mediawiki -o mtcars.txt mtcars.md

但是两个$符号被解释为<math>...</math>:

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?

推荐答案

pandoc文档说:

两个$字符之间的任何字符都将被视为TeX数学.这 开头的$必须在其右边立即有一个非空格字符, 而结尾的$必须在其后立即有一个非空格字符 左键,且不得紧随其后的数字.因此,$ 20,000 而$ 30,000不会解析为数学.如果出于某种原因您需要 用文字$字符括住文本,反斜杠转义它们,然后它们 将不会被视为数学定界符.

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  |

输出:

| |c1 |c2 | |:--|:----|:--| |7 |P$A |A | |8 |AB |B | |9 |P$A |C |

(我似乎没有获得与您相同的mediawiki输出格式,但是您明白了).

(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.

$符号的解释是称为tex_math_dollars的markdown扩展的一部分-您应该能够通过指定markdown-tex_math_dollarsmarkdown_strict的输入格式来完全抑制该符号(尽管在旧版本中不起作用)我在这里使用的Pandoc版本).

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).

这篇关于防止pandoc将$转换为mediawiki&lt; math&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆