Added angle_brackets_escapable extension.

This is needed because github flavored Markdown has a slightly
different set of escapable symbols than original Markdown;
it includes angle brackets.

Closes #2846.
This commit is contained in:
John MacFarlane 2016-10-22 23:41:55 +02:00
parent d2a6533d6e
commit 696dfbc993
3 changed files with 12 additions and 2 deletions

View file

@ -3332,6 +3332,12 @@ in pandoc, but may be enabled by adding `+EXTENSION` to the format
name, where `EXTENSION` is the name of the extension. Thus, for
example, `markdown+hard_line_breaks` is Markdown with hard line breaks.
#### Extension: `angle_brackets_escapable` ####
Allow `<` and `>` to be backslash-escaped, as they can be in
GitHub flavored Markdown but not original Markdown. This is
implied by pandoc's default `all_symbols_escapable`.
#### Extension: `lists_without_preceding_blankline` ####
Allow a list to occur right after a paragraph, with no intervening
@ -3475,7 +3481,7 @@ variants are supported:
: `pipe_tables`, `raw_html`, `fenced_code_blocks`, `auto_identifiers`,
`ascii_identifiers`, `backtick_code_blocks`, `autolink_bare_uris`,
`intraword_underscores`, `strikeout`, `hard_line_breaks`, `emoji`,
`shortcut_reference_links`.
`shortcut_reference_links`, `angle_brackets_escapable`.
`markdown_mmd` (MultiMarkdown)
: `pipe_tables`, `raw_html`, `markdown_attribute`, `mmd_link_attributes`,

View file

@ -101,6 +101,7 @@ data Extension =
-- space between items, and disallow laziness
| Ext_example_lists -- ^ Markdown-style numbered examples
| Ext_all_symbols_escapable -- ^ Make all non-alphanumerics escapable
| Ext_angle_brackets_escapable -- ^ Make < and > escapable
| Ext_intraword_underscores -- ^ Treat underscore inside word as literal
| Ext_blank_before_blockquote -- ^ Require blank line before a blockquote
| Ext_blank_before_header -- ^ Require blank line before a header
@ -204,7 +205,8 @@ phpMarkdownExtraExtensions = Set.fromList
githubMarkdownExtensions :: Set Extension
githubMarkdownExtensions = Set.fromList
[ Ext_pipe_tables
[ Ext_angle_brackets_escapable
, Ext_pipe_tables
, Ext_raw_html
, Ext_fenced_code_blocks
, Ext_auto_identifiers

View file

@ -1507,6 +1507,8 @@ escapedChar' :: MarkdownParser Char
escapedChar' = try $ do
char '\\'
(guardEnabled Ext_all_symbols_escapable >> satisfy (not . isAlphaNum))
<|> (guardEnabled Ext_angle_brackets_escapable >>
oneOf "\\`*_{}[]()>#+-.!~\"<>")
<|> oneOf "\\`*_{}[]()>#+-.!~\""
escapedChar :: MarkdownParser (F Inlines)