diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2014-04-05 21:02:12 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2014-04-05 21:02:12 -0700 |
commit | 24f438aa5f230464d510fae034c94644c0e181ca (patch) | |
tree | 7f6c465fc833ce6ce1910838c104c9d8fc8ee4e2 /src/Text/Pandoc | |
parent | 060a76a38e1f3586bc92787bb2c25c2dc04e380e (diff) | |
download | pandoc-24f438aa5f230464d510fae034c94644c0e181ca.tar.gz |
Textile reader: Better support for attributes.
Instead of being ignored, attributes are now parsed and
included in Span inlines.
The output will be a bit different from stock textile:
e.g. for `*(foo)hi*`, we'll get `<em><span class="foo">hi</span></em>`
instead of `<em class="foo">hi</em>`. But at least the data is
not lost.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/Textile.hs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs index f19d68e64..81994e6bd 100644 --- a/src/Text/Pandoc/Readers/Textile.hs +++ b/src/Text/Pandoc/Readers/Textile.hs @@ -604,15 +604,18 @@ ungroupedSimpleInline border construct = try $ do guard $ (stateQuoteContext st /= NoQuote) || (sourceColumn pos == 1) || isWhitespace - body <- surrounded border inlineWithAttribute - lookAhead (notFollowedBy alphaNum) - let result = construct $ mconcat body - return $ if isWhitespace then B.space <> result - else result - where - inlineWithAttribute = (try $ optional attributes) >> notFollowedBy (string "\n\n") - >> (withQuoteContext InSingleQuote inline) - + border *> notFollowedBy (oneOf " \t\n\r") + attr <- attributes + body <- trimInlines . mconcat <$> + withQuoteContext InSingleQuote + (manyTill inline (try border <* notFollowedBy alphaNum)) + let result = construct $ + if attr == nullAttr + then body + else B.spanWith attr body + return $ if isWhitespace + then B.space <> result + else result groupedSimpleInline :: Parser [Char] ParserState t -> (Inlines -> Inlines) |