aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2017-09-07 22:10:13 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2017-09-07 22:10:13 -0700
commit5fc4980216bf0a6b425827417655991859cba5ec (patch)
tree7f01fe4399d8aaffc52addb52e7d29b5bb16090b
parenta90f131937460f21005a997e0a1f10b930b203b2 (diff)
downloadpandoc-5fc4980216bf0a6b425827417655991859cba5ec.tar.gz
Markdown writer: Escape pipe characters when `pipe_tables` enabled.
Closes #3887.
-rw-r--r--src/Text/Pandoc/Writers/Markdown.hs1
-rw-r--r--test/command/3497.md2
2 files changed, 2 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Writers/Markdown.hs b/src/Text/Pandoc/Writers/Markdown.hs
index 3dbfe3f11..0221ba6ef 100644
--- a/src/Text/Pandoc/Writers/Markdown.hs
+++ b/src/Text/Pandoc/Writers/Markdown.hs
@@ -288,6 +288,7 @@ escapeString opts (c:cs) =
| otherwise -> "&gt;" ++ escapeString opts cs
_ | c `elem` ['\\','`','*','_','[',']','#'] ->
'\\':c:escapeString opts cs
+ '|' | isEnabled Ext_pipe_tables opts -> '\\':'|':escapeString opts cs
'^' | isEnabled Ext_superscript opts -> '\\':'^':escapeString opts cs
'~' | isEnabled Ext_subscript opts -> '\\':'~':escapeString opts cs
'$' | isEnabled Ext_tex_math_dollars opts -> '\\':'$':escapeString opts cs
diff --git a/test/command/3497.md b/test/command/3497.md
index 326817b0d..ca591cdd6 100644
--- a/test/command/3497.md
+++ b/test/command/3497.md
@@ -46,6 +46,6 @@ Also escape things that might become line blocks or tables:
% pandoc -t markdown
\| hi \|
^D
-\| hi |
+\| hi \|
```