git.iko.soy/typeable/pandoc
on master help sign in
TEI writer: remove heuristic to detect book template

TEI doesn't have `<book>` elements but only generic `<divN>` division elements. Checking the template for a trailing `</book>` is nonsensical.

commitaca695ab0bb5e18e3a2ea6d7b81d9814885c1b00 authorAlbert Krewinkel <albert@zeitkraut.de> dateTue 13 Sep 2016, 18:21 (10 years ago) parent23fb52e
1 file changed+5−9
src/Text/Pandoc/Writers/TEI.hs+5−9
src/Text/Pandoc/Writers/TEI.hs+5−9
@@ -35,7 +35,7 @@ import Text.Pandoc.Shared
3535import Text.Pandoc.Writers.Shared
3636import Text.Pandoc.Options
3737import Text.Pandoc.Templates (renderTemplate')
38−import Data.List ( stripPrefix, isPrefixOf, isSuffixOf )
38+import Data.List ( stripPrefix, isPrefixOf )
3939import Data.Char ( toLower )
4040import Text.Pandoc.Highlighting ( languages, languagesByExtension )
4141import Text.Pandoc.Pretty
@@ -60,19 +60,15 @@ writeTEI opts (Pandoc meta blocks) =
6060 then Just $ writerColumns opts
6161 else Nothing
6262 render' = render colwidth
63− opts' = if "/book>" `isSuffixOf`
64− (trimr $ writerTemplate opts)
65− then opts{ writerChapters = True }
66− else opts
67− startLvl = if writerChapters opts' then 0 else 1
63+ startLvl = if writerChapters opts then 0 else 1
6864 auths' = map (authorToTEI opts) $ docAuthors meta
6965 meta' = B.setMeta "author" auths' meta
7066 Just metadata = metaToJSON opts
7167 (Just . render colwidth . (vcat .
72− (map (elementToTEI opts' startLvl)) . hierarchicalize))
73− (Just . render colwidth . inlinesToTEI opts')
68+ (map (elementToTEI opts startLvl)) . hierarchicalize))
69+ (Just . render colwidth . inlinesToTEI opts)
7470 meta'
75− main = render' $ vcat (map (elementToTEI opts' startLvl) elements)
71+ main = render' $ vcat (map (elementToTEI opts startLvl) elements)
7672 context = defField "body" main
7773 $ defField "mathml" (case writerHTMLMathMethod opts of
7874 MathML _ -> True