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.
This commit is contained in:
John MacFarlane 2020-10-08 21:27:17 -07:00
parent dd3c4000ff
commit f19286cf12
2 changed files with 24 additions and 16 deletions

View file

@ -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

8
test/command/6719.md Normal file
View file

@ -0,0 +1,8 @@
```
% pandoc -f docbook -t native
<para>
<emphasis>emphasized </emphasis>text
</para>
^D
[Para [Emph [Str "emphasized"],Space,Str "text"]]
```