git.iko.soy/typeable/pandoc
on master help sign in
+ Changed 'escapedChar' in Markdown reader so that only the
d83b70ffiddlosopher
@@ -342,6 +342,28 @@ using the `hsmarkdown` wrapper.
342[standard markdown]: http://daringfireball.net/projects/markdown/syntax
342[standard markdown]: http://daringfireball.net/projects/markdown/syntax
343 "Markdown syntax description"
343 "Markdown syntax description"
344
344
345+Backslash escapes
346+-----------------
347+
348+Except inside a code block or inline code, any punctuation or space
349+character preceded by a backslash will be treated literally, even if it
350+would normally indicate formatting. Thus, for example, if one writes
351+
352+ *\*hello\**
353+
354+one will get
355+
356+ <em>*hello*</em>
357+
358+instead of
359+
360+ <strong>hello</strong>
361+
362+This rule is easier to remember than standard markdown's rule,
363+which allows only the following characters to be backslash-escaped:
364+
365+ \`*_{}[]()>#+-.!
366+
345Lists
367Lists
346-----
368-----
347
369
src/Text/Pandoc/Readers/Markdown.hs+8−1
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Markdown (
32 ) where
32 ) where
33
33
34import Data.List ( findIndex, sortBy )
34import Data.List ( findIndex, sortBy )
35+import Data.Char ( isAlphaNum )
35import Text.ParserCombinators.Pandoc
36import Text.ParserCombinators.Pandoc
36import Text.Pandoc.Definition
37import Text.Pandoc.Definition
37import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment )
38import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment )
@@ -535,7 +536,13 @@ inline = choice [ rawLaTeXInline', escapedChar, special, text ] <?> "inline"
535special = choice [ noteRef, inlineNote, link, referenceLink, rawHtmlInline',
536special = choice [ noteRef, inlineNote, link, referenceLink, rawHtmlInline',
536 autoLink, image ] <?> "link, inline html, note, or image"
537 autoLink, image ] <?> "link, inline html, note, or image"
537
538
538−escapedChar = escaped anyChar
539+escapedChar = try $ do
540+ char '\\'
541+ state <- getState
542+ result <- if stateStrict state
543+ then oneOf "\\`*_{}[]()>#+-.!"
544+ else satisfy (not . isAlphaNum)
545+ return (Str [result])
539
546
540ltSign = try (do
547ltSign = try (do
541 notFollowedBy (noneOf "<") -- continue only if it's a <
548 notFollowedBy (noneOf "<") -- continue only if it's a <