git.iko.soy/typeable/pandoc
on master help sign in
Extend fix to #6719 to JATS reader
commit2d4214fa3141f4a1cbde67f4e170a5bc5e639f32 authorJohn MacFarlane <jgm@berkeley.edu> dateThu 8 Oct 2020, 21:36 (6 years ago) parentf19286c
2 files changed+23−13
src/Text/Pandoc/Readers/JATS.hs+13−13 test/command/6719.md+10
src/Text/Pandoc/Readers/JATS.hs+13−13
@@ -26,7 +26,7 @@ import Text.HTML.TagSoup.Entity (lookupEntity)
2626import Text.Pandoc.Builder
2727import Text.Pandoc.Class.PandocMonad (PandocMonad)
2828import Text.Pandoc.Options
29−import Text.Pandoc.Shared (crFilter, safeRead)
29+import Text.Pandoc.Shared (crFilter, safeRead, extractSpaces)
3030import Text.TeXMath (readMathML, writeTeX)
3131import Text.XML.Light
3232import qualified Data.Set as S (fromList, member)
@@ -460,14 +460,14 @@ parseInline (CRef ref) =
460460 return . text . maybe (T.toUpper $ T.pack ref) T.pack $ lookupEntity ref
461461parseInline (Elem e) =
462462 case qName (elName e) of
463− "italic" -> emph <$> innerInlines
464− "bold" -> strong <$> innerInlines
465− "strike" -> strikeout <$> innerInlines
466− "sub" -> subscript <$> innerInlines
467− "sup" -> superscript <$> innerInlines
468− "underline" -> underline <$> innerInlines
463+ "italic" -> innerInlines emph
464+ "bold" -> innerInlines strong
465+ "strike" -> innerInlines strikeout
466+ "sub" -> innerInlines subscript
467+ "sup" -> innerInlines superscript
468+ "underline" -> innerInlines underline
469469 "break" -> return linebreak
470− "sc" -> smallcaps <$> innerInlines
470+ "sc" -> innerInlines smallcaps
471471
472472 "code" -> codeWithLang
473473 "monospace" -> codeWithLang
@@ -477,14 +477,14 @@ parseInline (Elem e) =
477477 qt <- gets jatsQuoteType
478478 let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
479479 modify $ \st -> st{ jatsQuoteType = qt' }
480− contents <- innerInlines
480+ contents <- innerInlines id
481481 modify $ \st -> st{ jatsQuoteType = qt }
482482 return $ if qt == SingleQuote
483483 then singleQuoted contents
484484 else doubleQuoted contents
485485
486486 "xref" -> do
487− ils <- innerInlines
487+ ils <- innerInlines id
488488 let rid = attrValue "rid" e
489489 let rids = T.words rid
490490 let refType = ("ref-type",) <$> maybeAttrValue "ref-type" e
@@ -501,7 +501,7 @@ parseInline (Elem e) =
501501 ils
502502 else linkWith attr ("#" <> rid) "" ils
503503 "ext-link" -> do
504− ils <- innerInlines
504+ ils <- innerInlines id
505505 let title = fromMaybe "" $ findAttrText (QName "title" (Just "http://www.w3.org/1999/xlink") Nothing) e
506506 let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of
507507 Just h -> T.pack h
@@ -520,8 +520,8 @@ parseInline (Elem e) =
520520 "uri" -> return $ link (textContent e) "" $ str $ textContent e
521521 "fn" -> note . mconcat <$>
522522 mapM parseBlock (elContent e)
523− _ -> innerInlines
524− where innerInlines = trimInlines . mconcat <$>
523+ _ -> innerInlines id
524+ where innerInlines f = extractSpaces f . mconcat <$>
525525 mapM parseInline (elContent e)
526526 mathML x =
527527 case readMathML . T.pack . showElement $ everywhere (mkT removePrefix) x of
test/command/6719.md+10
@@ -6,3 +6,13 @@
66^D
77[Para [Emph [Str "emphasized"],Space,Str "text"]]
88```
9+
10+```
11+% pandoc -f jats -t native
12+<p>
13+<italic> hi </italic>there
14+</p>
15+^D
16+[Para [Emph [Str "hi"],Space,Str "there"]]
17+```
18+