+ 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
This commit is contained in:
parent
3d0ee324f3
commit
d83b70f3a0
2 changed files with 30 additions and 1 deletions
22
README
22
README
|
@ -342,6 +342,28 @@ using the `hsmarkdown` wrapper.
|
|||
[standard markdown]: http://daringfireball.net/projects/markdown/syntax
|
||||
"Markdown syntax description"
|
||||
|
||||
Backslash escapes
|
||||
-----------------
|
||||
|
||||
Except inside a code block or inline code, any punctuation or space
|
||||
character preceded by a backslash will be treated literally, even if it
|
||||
would normally indicate formatting. Thus, for example, if one writes
|
||||
|
||||
*\*hello\**
|
||||
|
||||
one will get
|
||||
|
||||
<em>*hello*</em>
|
||||
|
||||
instead of
|
||||
|
||||
<strong>hello</strong>
|
||||
|
||||
This rule is easier to remember than standard markdown's rule,
|
||||
which allows only the following characters to be backslash-escaped:
|
||||
|
||||
\`*_{}[]()>#+-.!
|
||||
|
||||
Lists
|
||||
-----
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ module Text.Pandoc.Readers.Markdown (
|
|||
) where
|
||||
|
||||
import Data.List ( findIndex, sortBy )
|
||||
import Data.Char ( isAlphaNum )
|
||||
import Text.ParserCombinators.Pandoc
|
||||
import Text.Pandoc.Definition
|
||||
import Text.Pandoc.Readers.LaTeX ( rawLaTeXInline, rawLaTeXEnvironment )
|
||||
|
@ -535,7 +536,13 @@ inline = choice [ rawLaTeXInline', escapedChar, special, text ] <?> "inline"
|
|||
special = choice [ noteRef, inlineNote, link, referenceLink, rawHtmlInline',
|
||||
autoLink, image ] <?> "link, inline html, note, or image"
|
||||
|
||||
escapedChar = escaped anyChar
|
||||
escapedChar = try $ do
|
||||
char '\\'
|
||||
state <- getState
|
||||
result <- if stateStrict state
|
||||
then oneOf "\\`*_{}[]()>#+-.!"
|
||||
else satisfy (not . isAlphaNum)
|
||||
return (Str [result])
|
||||
|
||||
ltSign = try (do
|
||||
notFollowedBy (noneOf "<") -- continue only if it's a <
|
||||
|
|
Loading…
Reference in a new issue