git.iko.soy/typeable/pandoc
on master help sign in
Markdown reader: Support RST-style line blocks.
6b5302eJohn MacFarlane
src/Text/Pandoc/Options.hs+2
@@ -95,6 +95,7 @@ data Extension =
95 | Ext_auto_identifiers -- ^ Automatic identifiers for headers
95 | Ext_auto_identifiers -- ^ Automatic identifiers for headers
96 | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
96 | Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
97 | Ext_implicit_header_references -- ^ Implicit reference links for headers
97 | Ext_implicit_header_references -- ^ Implicit reference links for headers
98+ | Ext_line_blocks -- ^ RST style line blocks
98 deriving (Show, Read, Enum, Eq, Ord, Bounded)
99 deriving (Show, Read, Enum, Eq, Ord, Bounded)
99
100
100pandocExtensions :: Set Extension
101pandocExtensions :: Set Extension
@@ -134,6 +135,7 @@ pandocExtensions = Set.fromList
134 , Ext_auto_identifiers
135 , Ext_auto_identifiers
135 , Ext_header_attributes
136 , Ext_header_attributes
136 , Ext_implicit_header_references
137 , Ext_implicit_header_references
138+ , Ext_line_blocks
137 ]
139 ]
138
140
139phpMarkdownExtraExtensions :: Set Extension
141phpMarkdownExtraExtensions :: Set Extension
src/Text/Pandoc/Readers/Markdown.hs+13−1
@@ -31,7 +31,7 @@ Conversion of markdown-formatted plain text to 'Pandoc' document.
31module Text.Pandoc.Readers.Markdown ( readMarkdown,
31module Text.Pandoc.Readers.Markdown ( readMarkdown,
32 readMarkdownWithWarnings ) where
32 readMarkdownWithWarnings ) where
33
33
34−import Data.List ( transpose, sortBy, findIndex, intercalate )
34+import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
35import qualified Data.Map as M
35import qualified Data.Map as M
36import Data.Ord ( comparing )
36import Data.Ord ( comparing )
37import Data.Char ( isAlphaNum, toLower )
37import Data.Char ( isAlphaNum, toLower )
@@ -350,6 +350,7 @@ block = choice [ codeBlockFenced
350 , header
350 , header
351 , rawTeXBlock
351 , rawTeXBlock
352 , htmlBlock
352 , htmlBlock
353+ , lineBlock
353 , table
354 , table
354 , codeBlockIndented
355 , codeBlockIndented
355 , lhsCodeBlock
356 , lhsCodeBlock
@@ -868,6 +869,17 @@ stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s
868 [(k,v) | (k,v) <- as, k /= "markdown"]
869 [(k,v) | (k,v) <- as, k /= "markdown"]
869 filterAttrib x = x
870 filterAttrib x = x
870
871
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+
871--
883--
872-- Tables
884-- Tables
873--
885--