git.iko.soy/typeable/pandoc
on master help sign in
+ Changed 'escapedChar' in Markdown reader so that only the

characters Markdown escapes are escaped in strict mode. When not in strict mode, Pandoc allows all non-alphanumeric characters to be escaped. + Added documentation of backslash escapes to README. git-svn-id: https://pandoc.googlecode.com/svn/trunk@461 788f1e2b-df1e-0410-8736-df70ead52e1b

commitd83b70f3a0d72c322b2c0da3c78d4478c20f7f93 authorfiddlosopher <fiddlosopher@788f1e2b-df1e-0410-8736-df70ead52e1b> dateMon 8 Jan 2007, 23:54 (20 years ago) parent3d0ee32
2 files changed+30−1
README+22 src/Text/Pandoc/Readers/Markdown.hs+8−1
README+22
@@ -342,6 +342,28 @@ using the `hsmarkdown` wrapper.
342342[standard markdown]: http://daringfireball.net/projects/markdown/syntax
343343 "Markdown syntax description"
344344
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+
345367Lists
346368-----
347369
src/Text/Pandoc/Readers/Markdown.hs+8−1
@@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Markdown (
3232 ) where
3333
3434import Data.List ( findIndex, sortBy )
35+import Data.Char ( isAlphaNum )
3536import Text.ParserCombinators.Pandoc
3637import Text.Pandoc.Definition
3738import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment )
@@ -535,7 +536,13 @@ inline = choice [ rawLaTeXInline', escapedChar, special, text ] <?> "inline"
535536special = choice [ noteRef, inlineNote, link, referenceLink, rawHtmlInline',
536537 autoLink, image ] <?> "link, inline html, note, or image"
537538
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])
539546
540547ltSign = try (do
541548 notFollowedBy (noneOf "<") -- continue only if it's a <