git.iko.soy/typeable/pandoc
on master help sign in
EPUB writer: Allow `lang` variable to set language in metadata.

Defaults to locale language if `lang` is not set.

commit4e30f24974a2aa698afcb7b3e639030c816e0a41 authorJohn MacFarlane <fiddlosopher@gmail.com> dateSun 1 Jan 2012, 14:32 (15 years ago) parentda84255
2 files changed+9−5
README+4−3 src/Text/Pandoc/Writers/EPUB.hs+5−2
README+4−3
@@ -418,9 +418,10 @@ Options
418418
419419 By default, pandoc will include the following metadata elements:
420420 `<dc:title>` (from the document title), `<dc:creator>` (from the
421− document authors), `<dc:language>` (from the locale), and
422− `<dc:identifier id="BookId">` (a randomly generated UUID). Any of
423− these may be overridden by elements in the metadata file.
421+ document authors), `<dc:language>` (from the `lang` variable, or,
422+ if is not set, the locale), and `<dc:identifier id="BookId">` (a
423+ randomly generated UUID). Any of these may be overridden by elements
424+ in the metadata file.
424425
425426`-D` *FORMAT*, `--print-default-template=`*FORMAT*
426427: Print the default template for an output *FORMAT*. (See `-t`
src/Text/Pandoc/Writers/EPUB.hs+5−2
@@ -120,8 +120,11 @@ writeEPUB mbStylesheet opts doc@(Pandoc meta _) = do
120120 let chapterEntries = zipWith chapterToEntry [1..] chapters
121121
122122 -- contents.opf
123− lang <- catch (liftM (takeWhile (/='.')) $ getEnv "LANG")
124− (\_ -> return "en-US")
123+ localeLang <- catch (liftM (takeWhile (/='.')) $ getEnv "LANG")
124+ (\_ -> return "en-US")
125+ let lang = case lookup "lang" (writerVariables opts') of
126+ Just x -> x
127+ Nothing -> localeLang
125128 uuid <- getRandomUUID
126129 let chapterNode ent = unode "item" !
127130 [("id", takeBaseName $ eRelativePath ent),