git.iko.soy/typeable/pandoc
on master help sign in
TEI improvements.

- Ensure that title element is always present, even if empty. - Put author tags in the template, rather than adding them in the writer. Closes #4839.

commit0910e9218728c85feb562745ed5eb44d586e824d authorJohn MacFarlane <jgm@berkeley.edu> dateThu 16 Aug 2018, 21:06 (8 years ago) parentfe312b0
2 files changed+2−17
data/templates/default.tei+1−3 src/Text/Pandoc/Writers/TEI.hs+1−14
data/templates/default.tei+1−3
@@ -3,11 +3,9 @@
33<teiHeader>
44 <fileDesc>
55 <titleStmt>
6−$if(title)$
76 <title>$title$</title>
8−$endif$
97$for(author)$
10− $author$
8+ <author>$author$</author>
119$endfor$
1210 </titleStmt>
1311 <publicationStmt>
src/Text/Pandoc/Writers/TEI.hs+1−14
@@ -35,7 +35,6 @@ import Prelude
3535import Data.Char (toLower)
3636import Data.List (isPrefixOf, stripPrefix)
3737import Data.Text (Text)
38−import qualified Text.Pandoc.Builder as B
3938import Text.Pandoc.Class (PandocMonad, report)
4039import Text.Pandoc.Definition
4140import Text.Pandoc.Highlighting (languages, languagesByExtension)
@@ -48,16 +47,6 @@ import Text.Pandoc.Templates (renderTemplate')
4847import Text.Pandoc.Writers.Shared
4948import Text.Pandoc.XML
5049
51−-- | Convert list of authors to a docbook <author> section
52−authorToTEI :: PandocMonad m => WriterOptions -> [Inline] -> m B.Inlines
53−authorToTEI opts name' = do
54− name <- render Nothing <$> inlinesToTEI opts name'
55− let colwidth = if writerWrapText opts == WrapAuto
56− then Just $ writerColumns opts
57− else Nothing
58− return $ B.rawInline "tei" $ render colwidth $
59− inTagsSimple "author" (text $ escapeStringForXML name)
60−
6150-- | Convert Pandoc document to string in Docbook format.
6251writeTEI :: PandocMonad m => WriterOptions -> Pandoc -> m Text
6352writeTEI opts (Pandoc meta blocks) = do
@@ -72,13 +61,11 @@ writeTEI opts (Pandoc meta blocks) = do
7261 TopLevelChapter -> 0
7362 TopLevelSection -> 1
7463 TopLevelDefault -> 1
75− auths' <- mapM (authorToTEI opts) $ docAuthors meta
76− let meta' = B.setMeta "author" auths' meta
7764 metadata <- metaToJSON opts
7865 (fmap (render' . vcat) .
7966 mapM (elementToTEI opts startLvl) . hierarchicalize)
8067 (fmap render' . inlinesToTEI opts)
81− meta'
68+ meta
8269 main <- (render' . vcat) <$> mapM (elementToTEI opts startLvl) elements
8370 let context = defField "body" main
8471 $