Extend fix to #6719 to JATS reader
This commit is contained in:
parent
f19286cf12
commit
2d4214fa31
2 changed files with 23 additions and 13 deletions
|
@ -26,7 +26,7 @@ import Text.HTML.TagSoup.Entity (lookupEntity)
|
|||
import Text.Pandoc.Builder
|
||||
import Text.Pandoc.Class.PandocMonad (PandocMonad)
|
||||
import Text.Pandoc.Options
|
||||
import Text.Pandoc.Shared (crFilter, safeRead)
|
||||
import Text.Pandoc.Shared (crFilter, safeRead, extractSpaces)
|
||||
import Text.TeXMath (readMathML, writeTeX)
|
||||
import Text.XML.Light
|
||||
import qualified Data.Set as S (fromList, member)
|
||||
|
@ -460,14 +460,14 @@ parseInline (CRef ref) =
|
|||
return . text . maybe (T.toUpper $ T.pack ref) T.pack $ lookupEntity ref
|
||||
parseInline (Elem e) =
|
||||
case qName (elName e) of
|
||||
"italic" -> emph <$> innerInlines
|
||||
"bold" -> strong <$> innerInlines
|
||||
"strike" -> strikeout <$> innerInlines
|
||||
"sub" -> subscript <$> innerInlines
|
||||
"sup" -> superscript <$> innerInlines
|
||||
"underline" -> underline <$> innerInlines
|
||||
"italic" -> innerInlines emph
|
||||
"bold" -> innerInlines strong
|
||||
"strike" -> innerInlines strikeout
|
||||
"sub" -> innerInlines subscript
|
||||
"sup" -> innerInlines superscript
|
||||
"underline" -> innerInlines underline
|
||||
"break" -> return linebreak
|
||||
"sc" -> smallcaps <$> innerInlines
|
||||
"sc" -> innerInlines smallcaps
|
||||
|
||||
"code" -> codeWithLang
|
||||
"monospace" -> codeWithLang
|
||||
|
@ -477,14 +477,14 @@ parseInline (Elem e) =
|
|||
qt <- gets jatsQuoteType
|
||||
let qt' = if qt == SingleQuote then DoubleQuote else SingleQuote
|
||||
modify $ \st -> st{ jatsQuoteType = qt' }
|
||||
contents <- innerInlines
|
||||
contents <- innerInlines id
|
||||
modify $ \st -> st{ jatsQuoteType = qt }
|
||||
return $ if qt == SingleQuote
|
||||
then singleQuoted contents
|
||||
else doubleQuoted contents
|
||||
|
||||
"xref" -> do
|
||||
ils <- innerInlines
|
||||
ils <- innerInlines id
|
||||
let rid = attrValue "rid" e
|
||||
let rids = T.words rid
|
||||
let refType = ("ref-type",) <$> maybeAttrValue "ref-type" e
|
||||
|
@ -501,7 +501,7 @@ parseInline (Elem e) =
|
|||
ils
|
||||
else linkWith attr ("#" <> rid) "" ils
|
||||
"ext-link" -> do
|
||||
ils <- innerInlines
|
||||
ils <- innerInlines id
|
||||
let title = fromMaybe "" $ findAttrText (QName "title" (Just "http://www.w3.org/1999/xlink") Nothing) e
|
||||
let href = case findAttr (QName "href" (Just "http://www.w3.org/1999/xlink") Nothing) e of
|
||||
Just h -> T.pack h
|
||||
|
@ -520,8 +520,8 @@ parseInline (Elem e) =
|
|||
"uri" -> return $ link (textContent e) "" $ str $ textContent e
|
||||
"fn" -> note . mconcat <$>
|
||||
mapM parseBlock (elContent e)
|
||||
_ -> innerInlines
|
||||
where innerInlines = trimInlines . mconcat <$>
|
||||
_ -> innerInlines id
|
||||
where innerInlines f = extractSpaces f . mconcat <$>
|
||||
mapM parseInline (elContent e)
|
||||
mathML x =
|
||||
case readMathML . T.pack . showElement $ everywhere (mkT removePrefix) x of
|
||||
|
|
|
@ -6,3 +6,13 @@
|
|||
^D
|
||||
[Para [Emph [Str "emphasized"],Space,Str "text"]]
|
||||
```
|
||||
|
||||
```
|
||||
% pandoc -f jats -t native
|
||||
<p>
|
||||
<italic> hi </italic>there
|
||||
</p>
|
||||
^D
|
||||
[Para [Emph [Str "hi"],Space,Str "there"]]
|
||||
```
|
||||
|
||||
|
|
Loading…
Reference in a new issue