summaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 12:34:18 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-01-13 12:34:18 -0800
commit6b5302e063de7fcaddde69c74dac9c3841db1c24 (patch)
tree675316c60e66fcaa6fbd87f683fb55044e802e1d /src/Text
parent0598cf0fee810f809e976cc7e564d07c55080d49 (diff)
Markdown reader: Support RST-style line blocks.
This depends on the new Ext_line_blocks extension.
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Options.hs2
-rw-r--r--src/Text/Pandoc/Readers/Markdown.hs14
2 files changed, 15 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Options.hs b/src/Text/Pandoc/Options.hs
index 35d1a2173..ae2afd6fc 100644
--- a/src/Text/Pandoc/Options.hs
+++ b/src/Text/Pandoc/Options.hs
@@ -95,6 +95,7 @@ data Extension =
| Ext_auto_identifiers -- ^ Automatic identifiers for headers
| Ext_header_attributes -- ^ Explicit header attributes {#id .class k=v}
| Ext_implicit_header_references -- ^ Implicit reference links for headers
+ | Ext_line_blocks -- ^ RST style line blocks
deriving (Show, Read, Enum, Eq, Ord, Bounded)
pandocExtensions :: Set Extension
@@ -134,6 +135,7 @@ pandocExtensions = Set.fromList
, Ext_auto_identifiers
, Ext_header_attributes
, Ext_implicit_header_references
+ , Ext_line_blocks
]
phpMarkdownExtraExtensions :: Set Extension
diff --git a/src/Text/Pandoc/Readers/Markdown.hs b/src/Text/Pandoc/Readers/Markdown.hs
index 37f12c2e0..e454fd58d 100644
--- a/src/Text/Pandoc/Readers/Markdown.hs
+++ b/src/Text/Pandoc/Readers/Markdown.hs
@@ -31,7 +31,7 @@ Conversion of markdown-formatted plain text to 'Pandoc' document.
module Text.Pandoc.Readers.Markdown ( readMarkdown,
readMarkdownWithWarnings ) where
-import Data.List ( transpose, sortBy, findIndex, intercalate )
+import Data.List ( transpose, sortBy, findIndex, intersperse, intercalate )
import qualified Data.Map as M
import Data.Ord ( comparing )
import Data.Char ( isAlphaNum, toLower )
@@ -350,6 +350,7 @@ block = choice [ codeBlockFenced
, header
, rawTeXBlock
, htmlBlock
+ , lineBlock
, table
, codeBlockIndented
, lhsCodeBlock
@@ -869,6 +870,17 @@ stripMarkdownAttribute s = renderTags' $ map filterAttrib $ parseTags s
filterAttrib x = x
--
+-- line block
+--
+
+lineBlock :: MarkdownParser (F Blocks)
+lineBlock = try $ do
+ guardEnabled Ext_line_blocks
+ lines' <- lineBlockLines >>=
+ mapM (parseFromString (trimInlinesF . mconcat <$> many inline))
+ return $ B.para <$> (mconcat $ intersperse (return B.linebreak) lines')
+
+--
-- Tables
--