aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorDaniele D'Orazio <d.dorazio96@gmail.com>2019-10-09 10:10:08 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2019-10-15 09:49:09 -0700
commit1425bf9a6549da00ca87832dc6f19d59269a6a83 (patch)
tree5afee855bf9c867ed2fce0edfd6ecf14fb04c02a /src/Text/Pandoc/Readers
parenta1977dd2d67e6ccbafaf7ac25f941bdd399469fa (diff)
downloadpandoc-1425bf9a6549da00ca87832dc6f19d59269a6a83.tar.gz
Add support for reading and writing <kbd> 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.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs10
1 files changed, 9 insertions, 1 deletions
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"],[]))