git.iko.soy/typeable/pandoc
on master help sign in
Org reader: parse `#+LANGUAGE` into `lang` metadata field

Fixes: #6845

commit5344dab8ebf29ff96dd9e0d1411e11b44e2ccccf authorAlbert Krewinkel <albert@zeitkraut.de> dateSun 22 Nov 2020, 12:50 (6 years ago) parentae52918
3 files changed+10−1
doc/org.md+4−1 src/Text/Pandoc/Readers/Org/Meta.hs+2 test/Tests/Readers/Org/Meta.hs+4
doc/org.md+4−1
@@ -22,7 +22,8 @@ The following export keywords are supported:
2222- EMAIL: author email address; passed as plain-text metadata
2323 field `email`, but not used by any default templates.
2424
25−- LANGUAGE: currently unsupported; use `#+LANG:` instead.
25+- LANGUAGE: document language; included as plain-text metadata
26+ field `lang`. The value should be a [BCP47 language tag].
2627
2728- SELECT_TAGS: tags which select a tree for export. Currently
2829 *unsupported*.
@@ -36,6 +37,8 @@ The following export keywords are supported:
3637 defaults to stdout unless a target has to be given as a command
3738 line option.
3839
40+[BCP47 language tag]: https://tools.ietf.org/html/bcp47
41+
3942Format-specific options
4043-----------------------
4144
src/Text/Pandoc/Readers/Org/Meta.hs+2
@@ -93,6 +93,8 @@ keywordHandlers = Map.fromList
9393 , "institute" ~~> lineOfInlines `parseThen` collectLines "institute"
9494 -- topic keywords
9595 , "keywords" ~~> lineOfInlines `parseThen` collectLines "keywords"
96+ -- document language
97+ , "language" ~~> fmap pure anyLine `parseThen` B.setMeta "lang"
9698 -- LaTeX-specific export settings
9799 , "latex_class" ~~> fmap pure anyLine `parseThen` B.setMeta "documentclass"
98100 , "latex_class_options" ~~>
test/Tests/Readers/Org/Meta.hs+4
@@ -112,6 +112,10 @@ tests =
112112 "#+institute: ACME Inc." =?>
113113 Pandoc (setMeta "institute" ("ACME Inc." :: Inlines) nullMeta) mempty
114114
115+ , "Document language" =:
116+ "#+LANGUAGE: de-DE" =?>
117+ Pandoc (setMeta "lang" (MetaString "de-DE") nullMeta) mempty
118+
115119 , testGroup "LaTeX"
116120 [ "LATEX_HEADER" =:
117121 "#+latex_header: \\usepackage{tikz}" =?>