git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Support RST-style line blocks.

This depends on the new Ext_line_blocks extension.

commit6b5302e063de7fcaddde69c74dac9c3841db1c24 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 13 Jan 2013, 12:34 (14 years ago) parent0598cf0
2 files changed+15−1
src/Text/Pandoc/Options.hs+2 src/Text/Pandoc/Readers/Markdown.hs+13−1
src/Text/Pandoc/Options.hs+2
@@ -95,6 +95,7 @@ data Extension =
9595 | Ext_auto_identifiers -- ^ Automatic identifiers for headers
9696 | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
9797 | Ext_implicit_header_references -- ^ Implicit reference links for headers
98+ | Ext_line_blocks -- ^ RST style line blocks
9899 deriving (Show, Read, Enum, Eq, Ord, Bounded)
99100
100101pandocExtensions :: Set Extension
@@ -134,6 +135,7 @@ pandocExtensions = Set.fromList
134135 , Ext_auto_identifiers
135136 , Ext_header_attributes
136137 , Ext_implicit_header_references
138+ , Ext_line_blocks
137139 ]
138140
139141phpMarkdownExtraExtensions :: Set Extension
src/Text/Pandoc/Readers/Markdown.hs+13−1
@@ -31,7 +31,7 @@ Conversion of markdown-formatted plain text to 'Pandoc' document.
3131module Text.Pandoc.Readers.Markdown ( readMarkdown,
3232 readMarkdownWithWarnings ) where
3333
34−import Data.List ( transpose, sortBy, findIndex, intercalate )
34+import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
3535import qualified Data.Map as M
3636import Data.Ord ( comparing )
3737import Data.Char ( isAlphaNum, toLower )
@@ -350,6 +350,7 @@ block = choice [ codeBlockFenced
350350 , header
351351 , rawTeXBlock
352352 , htmlBlock
353+ , lineBlock
353354 , table
354355 , codeBlockIndented
355356 , lhsCodeBlock
@@ -868,6 +869,17 @@ stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s
868869 [(k,v) | (k,v) <- as, k /= "markdown"]
869870 filterAttrib x = x
870871
872+--
873+-- line block
874+--
875+
876+lineBlock :: MarkdownParser (F Blocks)
877+lineBlock = try $ do
878+ guardEnabled Ext_line_blocks
879+ lines' <- lineBlockLines >>=
880+ mapM (parseFromString (trimInlinesF . mconcat <$> many inline))
881+ return $ B.para <$> (mconcat $ intersperse (return B.linebreak) lines')
882+
871883--
872884-- Tables
873885--