Commit 42d79206fc
Verified · cmc
Layout: unified · split
Sources/OrgCore/Export/ExportScope.swift +7 −3
| @@ -10,6 +10,10 @@ public enum ExportScope { | ||
| 10 | 10 | ("EXPORT_TITLE", "TITLE"), ("EXPORT_AUTHOR", "AUTHOR"), ("EXPORT_DATE", "DATE"), ("EXPORT_EMAIL", "EMAIL"), |
| 11 | 11 | ("EXPORT_OPTIONS", "OPTIONS"), ("EXPORT_SELECT_TAGS", "SELECT_TAGS"), ("EXPORT_EXCLUDE_TAGS", "EXCLUDE_TAGS"), |
| 12 | 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 | 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 | 33 | body = ExportPreprocess.shift(body, to: 1) |
| 30 | 34 | |
| 31 | 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 | |
| 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)) | |
| 35 | 39 | var lines = preamble(tree).filter { line in |
| 36 | 40 | guard let m = line.firstMatch(of: #/^#\+([^:\s]+):/#) else { return true } |
| 37 | 41 | return !replaced.contains(m.1.uppercased()) |