From 8a101cffe36f4d6301ff45fd1b491bad1fcf1244 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 6 Aug 2012 22:13:24 -0700 Subject: Support hard_line_breaks markdown extension. * Added Ext_hard_line_breaks. * Added section in README on non-pandoc extensions. * Exported pandocExtensions and strictExtensions in Text.Pandoc.Options. Closes #514. --- src/Text/Pandoc/Options.hs | 41 +++++++++++++++++++++++++++++++++++++ src/Text/Pandoc/Readers/Markdown.hs | 3 ++- src/pandoc.hs | 4 ++-- 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs index 46200d8f3..5fe92c1fd 100644 --- a/src/Text/Pandoc/Options.hs +++ b/src/Text/Pandoc/Options.hs @@ -29,6 +29,8 @@ Data structures and functions for representing parser and writer options. -} module Text.Pandoc.Options ( Extension(..) + , pandocExtensions + , strictExtensions , ReaderOptions(..) , HTMLMathMethod (..) , CiteMethod (..) @@ -74,8 +76,47 @@ data Extension = Ext_footnotes | Ext_strikeout | Ext_superscript | Ext_subscript + | Ext_hard_line_breaks deriving (Show, Read, Enum, Eq, Ord, Bounded) +pandocExtensions :: Set Extension +pandocExtensions = Set.fromList + [ Ext_footnotes + , Ext_inline_notes + , Ext_pandoc_title_blocks + , Ext_table_captions + -- , Ext_image_captions + , Ext_simple_tables + , Ext_multiline_tables + , Ext_grid_tables + , Ext_pipe_tables + , Ext_citations + , Ext_raw_tex + , Ext_tex_math + , Ext_latex_macros + , Ext_delimited_code_blocks + , Ext_inline_code_attributes + , Ext_markdown_in_html_blocks + , Ext_escaped_line_breaks + , Ext_autolink_code_spans + , Ext_fancy_lists + , Ext_startnum + , Ext_definition_lists + , Ext_example_lists + -- , Ext_header_identifiers + , Ext_all_symbols_escapable + , Ext_intraword_underscores + , Ext_blank_before_blockquote + , Ext_blank_before_header + -- , Ext_significant_bullets + , Ext_strikeout + , Ext_superscript + , Ext_subscript + ] + +strictExtensions :: Set Extension +strictExtensions = Set.empty + data ReaderOptions = ReaderOptions{ readerExtensions :: Set Extension -- ^ Syntax extensions , readerSmart :: Bool -- ^ Smart punctuation diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs index 795935860..030e677c8 100644 --- a/src/Text/Pandoc/Readers/Markdown.hs +++ b/src/Text/Pandoc/Readers/Markdown.hs @@ -1321,7 +1321,8 @@ endline = try $ do when (stateParserContext st == ListItemState) $ do notFollowedBy' bulletListStart notFollowedBy' anyOrderedListStart - return $ return B.space + (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak)) + <|> (return $ return B.space) -- -- links diff --git a/src/pandoc.hs b/src/pandoc.hs index 549378ef0..50dfb59f3 100644 --- a/src/pandoc.hs +++ b/src/pandoc.hs @@ -964,8 +964,8 @@ main = do else takeDirectory (head sources) let defaultExts = if strict - then Set.empty - else Set.fromList [minBound..maxBound] + then strictExtensions + else pandocExtensions let extensions = foldl (\acc (inc,ext) -> if inc then Set.insert ext acc -- cgit v1.2.3