diff options
author | John MacFarlane <jgm@berkeley.edu> | 2020-10-08 21:27:17 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-10-08 21:27:52 -0700 |
commit | f19286cf120f259c51a89b1b3643d437ede70a94 (patch) | |
tree | 031e8b571d46865bf0f878d25c94cbb09f1ddf40 | |
parent | dd3c4000ff4941d3ce943b4d18b8965d94496de1 (diff) | |
download | pandoc-f19286cf120f259c51a89b1b3643d437ede70a94.tar.gz |
DocBook reader: don't squelch space at end of emphasis element.
Instead, include it after the emphasis. Closes #6719.
Same fix was made for other inline elements, e.g. strikethrough.
-rw-r--r-- | src/Text/Pandoc/Readers/DocBook.hs | 32 | ||||
-rw-r--r-- | test/command/6719.md | 8 |
2 files changed, 24 insertions, 16 deletions
diff --git a/src/Text/Pandoc/Readers/DocBook.hs b/src/Text/Pandoc/Readers/DocBook.hs index 0635884ad..01d50d5c4 100644 --- a/src/Text/Pandoc/Readers/DocBook.hs +++ b/src/Text/Pandoc/Readers/DocBook.hs @@ -26,7 +26,7 @@ import Text.Pandoc.Builder import Text.Pandoc.Class.PandocMonad (PandocMonad, report) import Text.Pandoc.Options import Text.Pandoc.Logging (LogMessage(..)) -import Text.Pandoc.Shared (crFilter, safeRead) +import Text.Pandoc.Shared (crFilter, safeRead, extractSpaces) import Text.TeXMath (readMathML, writeTeX) import Text.XML.Light @@ -1065,19 +1065,19 @@ parseInline (Elem e) = let ident = attrValue "id" e let classes = T.words $ attrValue "class" e if ident /= "" || classes /= [] - then spanWith (ident,classes,[]) <$> innerInlines - else innerInlines + then innerInlines (spanWith (ident,classes,[])) + else innerInlines id "equation" -> equation e displayMath "informalequation" -> equation e displayMath "inlineequation" -> equation e math - "subscript" -> subscript <$> innerInlines - "superscript" -> superscript <$> innerInlines + "subscript" -> innerInlines subscript + "superscript" -> innerInlines superscript "inlinemediaobject" -> getMediaobject e "quote" -> do qt <- gets dbQuoteType let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote modify $ \st -> st{ dbQuoteType = qt' } - contents <- innerInlines + contents <- innerInlines id modify $ \st -> st{ dbQuoteType = qt } return $ if qt == SingleQuote then singleQuoted contents @@ -1098,7 +1098,7 @@ parseInline (Elem e) = "replaceable" -> do x <- getInlines e return $ str "<" <> x <> str ">" "markup" -> codeWithLang - "wordasword" -> emph <$> innerInlines + "wordasword" -> innerInlines emph "command" -> codeWithLang "varname" -> codeWithLang "function" -> codeWithLang @@ -1126,21 +1126,21 @@ parseInline (Elem e) = "email" -> return $ link ("mailto:" <> T.pack (strContent e)) "" $ str $ T.pack $ strContent e "uri" -> return $ link (T.pack $ strContent e) "" $ str $ T.pack $ strContent e - "ulink" -> link (attrValue "url" e) "" <$> innerInlines + "ulink" -> innerInlines (link (attrValue "url" e) "") "link" -> do - ils <- innerInlines + ils <- innerInlines id let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of Just h -> T.pack h _ -> "#" <> attrValue "linkend" e let ils' = if ils == mempty then str href else ils let attr = (attrValue "id" e, T.words $ attrValue "role" e, []) return $ linkWith attr href "" ils' - "foreignphrase" -> emph <$> innerInlines + "foreignphrase" -> innerInlines emph "emphasis" -> case attrValue "role" e of - "bold" -> strong <$> innerInlines - "strong" -> strong <$> innerInlines - "strikethrough" -> strikeout <$> innerInlines - _ -> emph <$> innerInlines + "bold" -> innerInlines strong + "strong" -> innerInlines strong + "strikethrough" -> innerInlines strikeout + _ -> innerInlines emph "footnote" -> note . mconcat <$> mapM parseBlock (elContent e) "title" -> return mempty @@ -1149,12 +1149,12 @@ parseInline (Elem e) = -- <?asciidor-br?> to in handleInstructions, above. A kludge to -- work around xml-light's inability to parse an instruction. "br" -> return linebreak - _ -> skip >> innerInlines + _ -> skip >> innerInlines id where skip = do lift $ report $ IgnoredElement $ T.pack $ qName (elName e) return mempty - innerInlines = trimInlines . mconcat <$> + innerInlines f = extractSpaces f . mconcat <$> mapM parseInline (elContent e) codeWithLang = do let classes' = case attrValue "language" e of diff --git a/test/command/6719.md b/test/command/6719.md new file mode 100644 index 000000000..96c97b365 --- /dev/null +++ b/test/command/6719.md @@ -0,0 +1,8 @@ +``` +% pandoc -f docbook -t native +<para> +<emphasis>emphasized </emphasis>text +</para> +^D +[Para [Emph [Str "emphasized"],Space,Str "text"]] +``` |