diff options
| author | John MacFarlane <jgm@berkeley.edu> | 2022-12-15 12:38:36 -0800 |
|---|---|---|
| committer | John MacFarlane <jgm@berkeley.edu> | 2022-12-15 12:38:36 -0800 |
| commit | 1698af8885d1d8a4e4ed9cdd03274c0e7446acd0 (patch) | |
| tree | df37b8dffb699e699daa31cf7e570c948fdff803 /src/Text | |
| parent | 200ad70d9d9e7963e710525481cc32d16177c636 (diff) | |
Textile reader: handle empty paragraphs.
Also, if attributes are added explicitly to a paragraph,
put it in a Div with the attributes.
Closes #8487.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index e28ac52f6..9b325ce0f 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -121,7 +121,8 @@ blockParsers = [ codeBlock , rawHtmlBlock , rawLaTeXBlock' , table - , maybeExplicitBlock "p" para + , explicitBlock "p" (para <|> pure (B.para mempty)) + , para , mempty <$ blanklines ] @@ -148,7 +149,7 @@ codeBlockTextile = try $ do char ' ' let starts = ["p", "table", "bq", "bc", "pre", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "###", "notextile"] - let ender = choice $ map explicitBlockStart starts + let ender = () <$ choice (map explicitBlockStart starts) contents <- if extended then do f <- anyLine @@ -436,25 +437,27 @@ ignorableRow = try $ do _ <- anyLine return () -explicitBlockStart :: PandocMonad m => Text -> TextileParser m () +explicitBlockStart :: PandocMonad m => Text -> TextileParser m Attr explicitBlockStart name = try $ do string (T.unpack name) - attributes + attr <- attributes char '.' optional whitespace optional endline + return attr -- | Blocks like 'p' and 'table' do not need explicit block tag. -- However, they can be used to set HTML/CSS attributes when needed. -maybeExplicitBlock :: PandocMonad m - => Text -- ^ block tag name - -> TextileParser m Blocks -- ^ implicit block - -> TextileParser m Blocks -maybeExplicitBlock name blk = try $ do - optional $ explicitBlockStart name - blk - - +explicitBlock :: PandocMonad m + => Text -- ^ block tag name + -> TextileParser m Blocks -- ^ implicit block + -> TextileParser m Blocks +explicitBlock name blk = try $ do + attr <- explicitBlockStart name + contents <- blk + return $ if attr == nullAttr + then contents + else B.divWith attr contents ---------- -- Inlines |
