git.iko.soy/typeable/pandoc
on master help sign in
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.

commit8a101cffe36f4d6301ff45fd1b491bad1fcf1244 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 6 Aug 2012, 22:13 (14 years ago) parentdc071f8
4 files changed+55−3
README+10 src/Text/Pandoc/Options.hs+41 src/Text/Pandoc/Readers/Markdown.hs+2−1 src/pandoc.hs+2−2
README+10
@@ -2171,6 +2171,16 @@ document with an appropriate header:
21712171
21722172The bibliography will be inserted after this header.
21732173
2174+Non-pandoc extensions
2175+=====================
2176+
2177+The following markdown syntax extensions are not enabled by default
2178+in pandoc, but can be enabled using the `-e` (`--enable`) option:
2179+
2180+**Extension: `hard_line_breaks`**\
2181+Causes all newlines within a paragraph to be interpreted as hard line
2182+breaks instead of spaces.
2183+
21742184
21752185Producing slide shows with Pandoc
21762186=================================
src/Text/Pandoc/Options.hs+41
@@ -29,6 +29,8 @@ Data structures and functions for representing parser and writer
2929options.
3030-}
3131module Text.Pandoc.Options ( Extension(..)
32+ , pandocExtensions
33+ , strictExtensions
3234 , ReaderOptions(..)
3335 , HTMLMathMethod (..)
3436 , CiteMethod (..)
@@ -74,8 +76,47 @@ data Extension = Ext_footnotes
7476 | Ext_strikeout
7577 | Ext_superscript
7678 | Ext_subscript
79+ | Ext_hard_line_breaks
7780 deriving (Show, Read, Enum, Eq, Ord, Bounded)
7881
82+pandocExtensions :: Set Extension
83+pandocExtensions = Set.fromList
84+ [ Ext_footnotes
85+ , Ext_inline_notes
86+ , Ext_pandoc_title_blocks
87+ , Ext_table_captions
88+ -- , Ext_image_captions
89+ , Ext_simple_tables
90+ , Ext_multiline_tables
91+ , Ext_grid_tables
92+ , Ext_pipe_tables
93+ , Ext_citations
94+ , Ext_raw_tex
95+ , Ext_tex_math
96+ , Ext_latex_macros
97+ , Ext_delimited_code_blocks
98+ , Ext_inline_code_attributes
99+ , Ext_markdown_in_html_blocks
100+ , Ext_escaped_line_breaks
101+ , Ext_autolink_code_spans
102+ , Ext_fancy_lists
103+ , Ext_startnum
104+ , Ext_definition_lists
105+ , Ext_example_lists
106+ -- , Ext_header_identifiers
107+ , Ext_all_symbols_escapable
108+ , Ext_intraword_underscores
109+ , Ext_blank_before_blockquote
110+ , Ext_blank_before_header
111+ -- , Ext_significant_bullets
112+ , Ext_strikeout
113+ , Ext_superscript
114+ , Ext_subscript
115+ ]
116+
117+strictExtensions :: Set Extension
118+strictExtensions = Set.empty
119+
79120data ReaderOptions = ReaderOptions{
80121 readerExtensions :: Set Extension -- ^ Syntax extensions
81122 , readerSmart :: Bool -- ^ Smart punctuation
src/Text/Pandoc/Readers/Markdown.hs+2−1
@@ -1321,7 +1321,8 @@ endline = try $ do
13211321 when (stateParserContext st == ListItemState) $ do
13221322 notFollowedBy' bulletListStart
13231323 notFollowedBy' anyOrderedListStart
1324− return $ return B.space
1324+ (guardEnabled Ext_hard_line_breaks >> return (return B.linebreak))
1325+ <|> (return $ return B.space)
13251326
13261327--
13271328-- links
src/pandoc.hs+2−2
@@ -964,8 +964,8 @@ main = do
964964 else takeDirectory (head sources)
965965
966966 let defaultExts = if strict
967− then Set.empty
968− else Set.fromList [minBound..maxBound]
967+ then strictExtensions
968+ else pandocExtensions
969969
970970 let extensions = foldl (\acc (inc,ext) -> if inc
971971 then Set.insert ext acc