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 {
10 ("EXPORT_TITLE", "TITLE"), ("EXPORT_AUTHOR", "AUTHOR"), ("EXPORT_DATE", "DATE"), ("EXPORT_EMAIL", "EMAIL"), 10 ("EXPORT_TITLE", "TITLE"), ("EXPORT_AUTHOR", "AUTHOR"), ("EXPORT_DATE", "DATE"), ("EXPORT_EMAIL", "EMAIL"),
11 ("EXPORT_OPTIONS", "OPTIONS"), ("EXPORT_SELECT_TAGS", "SELECT_TAGS"), ("EXPORT_EXCLUDE_TAGS", "EXCLUDE_TAGS"), 11 ("EXPORT_OPTIONS", "OPTIONS"), ("EXPORT_SELECT_TAGS", "SELECT_TAGS"), ("EXPORT_EXCLUDE_TAGS", "EXCLUDE_TAGS"),
12 ("EXPORT_HTML_HEAD", "HTML_HEAD"), ("EXPORT_HTML_HEAD_EXTRA", "HTML_HEAD_EXTRA"), 12 ("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"),
13 ] 17 ]
14 18
15 /// The subtree containing `offset` as a document of its own: the file's keyword lines, then 19 /// The subtree containing `offset` as a document of its own: the file's keyword lines, then
@@ -29,9 +33,9 @@ public enum ExportScope {
29 body = ExportPreprocess.shift(body, to: 1) 33 body = ExportPreprocess.shift(body, to: 1)
30 34
31 let property = { (key: String) in heading.properties.last { $0.key.uppercased() == key }?.value } 35 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 36 // What the subtree sets replaces the file's keywords; `EXPORT_OPTIONS` only the items
33 // otherwise join. 37 // it names.
34 let replaced = Set(overrides.prefix(4).filter { $0.property == "EXPORT_TITLE" || property($0.property) != nil }.map(\.keyword)) 38 let replaced = Set(overrides.filter { $0.property == "EXPORT_TITLE" || ($0.property != "EXPORT_OPTIONS" && property($0.property) != nil) }.map(\.keyword))
35 var lines = preamble(tree).filter { line in 39 var lines = preamble(tree).filter { line in
36 guard let m = line.firstMatch(of: #/^#\+([^:\s]+):/#) else { return true } 40 guard let m = line.firstMatch(of: #/^#\+([^:\s]+):/#) else { return true }
37 return !replaced.contains(m.1.uppercased()) 41 return !replaced.contains(m.1.uppercased())