From 696dfbc993691933f01241bbb7f2f379f45b99a5 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 22 Oct 2016 23:41:55 +0200 Subject: 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. --- MANUAL.txt | 8 +++++++- src/Text/Pandoc/Options.hs | 4 +++- src/Text/Pandoc/Readers/Markdown.hs | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/MANUAL.txt b/MANUAL.txt index 6cabf1941..16d562ca0 100644 --- a/MANUAL.txt +++ b/MANUAL.txt @@ -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`, diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 575250b9e..6c7dde488 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -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 diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 68bc936b1..2337b733a 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -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) -- cgit v1.2.3