aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Readers/HTML.hs13
-rw-r--r--test/command/1592.md21
2 files changed, 34 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Readers/HTML.hs b/src/Text/Pandoc/Readers/HTML.hs
index 6cfef0ebe..798661fe3 100644
--- a/src/Text/Pandoc/Readers/HTML.hs
+++ b/src/Text/Pandoc/Readers/HTML.hs
@@ -648,6 +648,7 @@ inline = choice
, pLineBreak
, pLink
, pImage
+ , pBdo
, pCode
, pCodeWithClass [("samp","sample"),("var","variable")]
, pSpan
@@ -802,6 +803,18 @@ pCode = try $ do
result <- manyTill pAny (pCloses open)
return $ B.codeWith (mkAttr attr) $ T.unwords $ T.lines $ innerText result
+-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/bdo
+-- Bidirectional Text Override
+pBdo :: PandocMonad m => TagParser m Inlines
+pBdo = try $ do
+ TagOpen _ attr' <- lookAhead $ pSatisfy $ tagOpen (=="bdo") (const True)
+ let attr = toStringAttr attr'
+ contents <- pInTags "bdo" inline
+ return $ case lookup "dir" attr of
+ -- Only bdo with a direction matters
+ Just dir -> B.spanWith ("", [], [("dir",T.toLower dir)]) contents
+ Nothing -> contents
+
pSpan :: PandocMonad m => TagParser m Inlines
pSpan = try $ do
guardEnabled Ext_native_spans
diff --git a/test/command/1592.md b/test/command/1592.md
index 54e59137b..0f6151063 100644
--- a/test/command/1592.md
+++ b/test/command/1592.md
@@ -47,3 +47,24 @@ pandoc -f native -t markdown
[hi]{.smallcaps}
```
+```
+% pandoc -f html -t native
+<bdo dir="ltr">foo</bdo>
+^D
+[Plain [Span ("",[],[("dir","ltr")]) [Str "foo"]]]
+```
+
+```
+% pandoc -f html -t native
+<bdo dir="rtl">foo<bdo dir="ltr">bar</bdo>baz</bdo>
+^D
+[Plain [Span ("",[],[("dir","rtl")]) [Str "foo",Span ("",[],[("dir","ltr")]) [Str "bar"],Str "baz"]]]
+```
+
+```
+% pandoc -f html -t native
+<p><bdo dir="rtl">This text will go right
+to left.</bdo></p>
+^D
+[Para [Span ("",[],[("dir","rtl")]) [Str "This",Space,Str "text",Space,Str "will",Space,Str "go",Space,Str "right",SoftBreak,Str "to",Space,Str "left."]]]
+```