From 1425bf9a6549da00ca87832dc6f19d59269a6a83 Mon Sep 17 00:00:00 2001 From: Daniele D'Orazio Date: Wed, 9 Oct 2019 10:10:08 +0200 Subject: Add support for reading and writing elements * Text.Pandoc.Shared: export `htmlSpanLikeElements` [API change] This commit also introduces a mapping of HTML span like elements that are internally represented as a Span with a single class, but that are converted back to the original element by the html writer. As of now, only the kbd element is handled this way. Ideally these elements should be handled as plain AST values, but since that would be a breaking change with a large impact, we revert to this stop-gap solution. Fixes https://github.com/jgm/pandoc/issues/5796. --- src/Text/Pandoc/Readers/HTML.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/Text/Pandoc/Readers') diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs index bb4e3a913..a9a04c962 100644 --- a/src/Text/Pandoc/Readers/HTML.hs +++ b/src/Text/Pandoc/Readers/HTML.hs @@ -62,7 +62,8 @@ import Text.Pandoc.Options ( extensionEnabled) import Text.Pandoc.Parsing hiding ((<|>)) import Text.Pandoc.Shared (addMetaField, blocksToInlines', crFilter, escapeURI, - extractSpaces, onlySimpleTableCells, safeRead, underlineSpan) + extractSpaces, htmlSpanLikeElements, + onlySimpleTableCells, safeRead, underlineSpan) import Text.Pandoc.Walk import Text.Parsec.Error import Text.TeXMath (readMathML, writeTeX) @@ -643,6 +644,7 @@ inline = choice , pStrong , pSuperscript , pSubscript + , pSpanLike , pSmall , pStrikeout , pUnderline @@ -707,6 +709,12 @@ pSuperscript = pInlinesInTags "sup" B.superscript pSubscript :: PandocMonad m => TagParser m Inlines pSubscript = pInlinesInTags "sub" B.subscript +pSpanLike :: PandocMonad m => TagParser m Inlines +pSpanLike = Set.foldr + (\tag acc -> acc <|> pInlinesInTags tag (B.spanWith ("",[T.unpack tag],[]))) + mzero + htmlSpanLikeElements + pSmall :: PandocMonad m => TagParser m Inlines pSmall = pInlinesInTags "small" (B.spanWith ("",["small"],[])) -- cgit v1.2.3