Commit 42d79206fc

42d79206fcc92d2fb7ef09014cffa08ddf416e00

parent: dc4642653b

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-20 17:53 UTC

Apply a subtree's LaTeX and keyword properties in place of the file's

Layout: unified · split

Sources/OrgCore/Export/ExportScope.swift +7 −3
@@ -10,6 +10,10 @@ public enum ExportScope {
1010 ("EXPORT_TITLE", "TITLE"), ("EXPORT_AUTHOR", "AUTHOR"), ("EXPORT_DATE", "DATE"), ("EXPORT_EMAIL", "EMAIL"),
1111 ("EXPORT_OPTIONS", "OPTIONS"), ("EXPORT_SELECT_TAGS", "SELECT_TAGS"), ("EXPORT_EXCLUDE_TAGS", "EXCLUDE_TAGS"),
1212 ("EXPORT_HTML_HEAD", "HTML_HEAD"), ("EXPORT_HTML_HEAD_EXTRA", "HTML_HEAD_EXTRA"),
13 ("EXPORT_SUBTITLE", "SUBTITLE"), ("EXPORT_KEYWORDS", "KEYWORDS"), ("EXPORT_DESCRIPTION", "DESCRIPTION"), ("EXPORT_LANGUAGE", "LANGUAGE"),
14 ("EXPORT_LATEX_CLASS", "LATEX_CLASS"), ("EXPORT_LATEX_CLASS_OPTIONS", "LATEX_CLASS_OPTIONS"), ("EXPORT_LATEX_HEADER", "LATEX_HEADER"),
15 ("EXPORT_LATEX_HEADER_EXTRA", "LATEX_HEADER_EXTRA"), ("EXPORT_LATEX_COMPILER", "LATEX_COMPILER"),
16 ("EXPORT_LATEX_CLASS_PRE", "LATEX_CLASS_PRE"), ("EXPORT_LATEX_FOOTNOTE_COMMAND", "LATEX_FOOTNOTE_COMMAND"), ("EXPORT_CITE_EXPORT", "CITE_EXPORT"),
1317 ]
1418
1519 /// The subtree containing `offset` as a document of its own: the file's keyword lines, then
@@ -29,9 +33,9 @@ public enum ExportScope {
2933 body = ExportPreprocess.shift(body, to: 1)
3034
3135 let property = { (key: String) in heading.properties.last { $0.key.uppercased() == key }?.value }
32 // The title, author and date the subtree sets replace the file's, which Org would
33 // otherwise join.
34 let replaced = Set(overrides.prefix(4).filter { $0.property == "EXPORT_TITLE" || property($0.property) != nil }.map(\.keyword))
36 // What the subtree sets replaces the file's keywords; `EXPORT_OPTIONS` only the items
37 // it names.
38 let replaced = Set(overrides.filter { $0.property == "EXPORT_TITLE" || ($0.property != "EXPORT_OPTIONS" && property($0.property) != nil) }.map(\.keyword))
3539 var lines = preamble(tree).filter { line in
3640 guard let m = line.firstMatch(of: #/^#\+([^:\s]+):/#) else { return true }
3741 return !replaced.contains(m.1.uppercased())