mirror of
https://github.com/jgm/pandoc.git
synced 2026-08-28 17:20:47 +08:00
DocBook/JATS reader: don't export surrounding space from inline elements.
Previously we would export leading and trailing space inside elements like emphasis or ulink so they appeared outside the resulting pandoc Inline (Emph or Link). This is not really motivated; DocBook and XML in general treats leading and trailing whitespace in this context as significant. These spaces may casue problems for some output formats, e.g. asciidoc, but these issues should be addressed in the corresponding writers, as they are in the Markdown writer, using Text.Pandoc.Writers.Shared.delimited. Closes #11398.
This commit is contained in:
@@ -46,7 +46,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 (safeRead, extractSpaces, addPandocAttributes)
|
||||
import Text.Pandoc.Shared (safeRead, addPandocAttributes)
|
||||
import Text.Pandoc.Sources (ToSources(..), sourcesToText)
|
||||
import Text.Pandoc.Transforms (headerShift)
|
||||
import Text.TeXMath (readMathML, writeTeX)
|
||||
@@ -1380,8 +1380,7 @@ parseInline (Elem e) = do
|
||||
lift $ report $ IgnoredElement name
|
||||
return mempty
|
||||
|
||||
innerInlines f = extractSpaces f . mconcat <$>
|
||||
mapM parseInline (elContent e)
|
||||
innerInlines f = f . mconcat <$> mapM parseInline (elContent e)
|
||||
codeWithLang = do
|
||||
let classes' = case attrValue "language" e of
|
||||
"" -> []
|
||||
|
||||
@@ -31,7 +31,7 @@ import Text.Pandoc.XML (lookupEntity)
|
||||
import Text.Pandoc.Builder
|
||||
import Text.Pandoc.Class.PandocMonad (PandocMonad)
|
||||
import Text.Pandoc.Options
|
||||
import Text.Pandoc.Shared (safeRead, extractSpaces)
|
||||
import Text.Pandoc.Shared (safeRead)
|
||||
import Text.Pandoc.Walk (walk)
|
||||
import Text.Pandoc.XML.Light
|
||||
import Text.TeXMath (readMathML, writeTeX)
|
||||
@@ -733,8 +733,7 @@ parseInline (Elem e) =
|
||||
"fn" -> note . mconcat <$>
|
||||
mapM parseBlock (elContent e)
|
||||
_ -> innerInlines id
|
||||
where innerInlines f = extractSpaces f . mconcat <$>
|
||||
mapM parseInline (elContent e)
|
||||
where innerInlines f = f . mconcat <$> mapM parseInline (elContent e)
|
||||
codeWithLang = do
|
||||
let classes' = case attrValue "language" e of
|
||||
"" -> []
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<emphasis>emphasized </emphasis>text
|
||||
</para>
|
||||
^D
|
||||
[ Para [ Emph [ Str "emphasized" ] , Space , Str "text" ] ]
|
||||
[ Para [ Emph [ Str "emphasized" , Space ] , Str "text" ] ]
|
||||
```
|
||||
|
||||
```
|
||||
@@ -13,6 +13,6 @@
|
||||
<italic> hi </italic>there
|
||||
</p>
|
||||
^D
|
||||
[ Para [ Emph [ Str "hi" ] , Space , Str "there" ] ]
|
||||
[ Para [ Emph [ Space , Str "hi" , Space ] , Str "there" ] ]
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user