diff options
| author | John MacFarlane <[email protected]> | 2024-07-03 22:26:51 -0700 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2024-07-03 22:26:51 -0700 |
| commit | b65006d3e64172756fded9d4ad1c80f78f0e5efc (patch) | |
| tree | d6459979ea7c851ad36fe03814ee7a7803696095 /src/Text | |
| parent | c4cf6b26637dcb0c3b2846ef123e7adc06d95467 (diff) | |
Avoid 'head' in JATS reader, DocBook writer.
Diffstat (limited to 'src/Text')
| -rw-r--r-- | src/Text/Pandoc/Readers/JATS.hs | 4 | ||||
| -rw-r--r-- | src/Text/Pandoc/Writers/DocBook.hs | 7 |
2 files changed, 6 insertions, 5 deletions
diff --git a/src/Text/Pandoc/Readers/JATS.hs b/src/Text/Pandoc/Readers/JATS.hs index 0da3bb1ef..dcfce6fcd 100644 --- a/src/Text/Pandoc/Readers/JATS.hs +++ b/src/Text/Pandoc/Readers/JATS.hs @@ -757,7 +757,9 @@ blockFormula constructor e = do filterChildren (named "tex-math") whereToLook mathMLs = map mathML $ filterChildren isMathML whereToLook - return . para . head . take 1 . map constructor $ texMaths ++ mathMLs + case texMaths ++ mathMLs of + [] -> return mempty + (m:_) -> return $ para (constructor m) mathML :: Element -> Text mathML x = diff --git a/src/Text/Pandoc/Writers/DocBook.hs b/src/Text/Pandoc/Writers/DocBook.hs index 28238930c..bae20c6dc 100644 --- a/src/Text/Pandoc/Writers/DocBook.hs +++ b/src/Text/Pandoc/Writers/DocBook.hs @@ -251,10 +251,9 @@ blockToDocBook opts (BlockQuote blocks) = blockToDocBook opts (CodeBlock (_,classes,_) str) = return $ literal ("<programlisting" <> lang <> ">") <> cr <> flush (literal (escapeStringForXML str) <> cr <> literal "</programlisting>") - where lang = if null langs - then "" - else " language=\"" <> escapeStringForXML (head langs) <> - "\"" + where lang = case langs of + [] -> "" + (l:_) -> " language=\"" <> escapeStringForXML l <> "\"" syntaxMap = writerSyntaxMap opts isLang l = T.toLower l `elem` map T.toLower (languages syntaxMap) langsFrom s = if isLang s |
