Commit 19f9854b18

19f9854b18b7152959f32c359db2d94fe4ad7f5a

parent: 7f51ed1c5b

Verified · cmc

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

Show LaTeX refusals on iOS and when publishing

Layout: unified · split

Sources/Orgstar/ContentView.swift +5 −1
@@ -982,7 +982,11 @@ struct ContentView: View {
982 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile) 982 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
983 if function == "org-md-publish-to-md" { return MarkdownExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly) } 983 if function == "org-md-publish-to-md" { return MarkdownExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly) }
984 if function == "org-latex-publish-to-latex" { 984 if function == "org-latex-publish-to-latex" {
985 return try LaTeXExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: NSFullUserName(), language: OrgPreferences.exportLanguage(), file: true) 985 do {
986 return try LaTeXExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly, author: NSFullUserName(), language: OrgPreferences.exportLanguage(), file: true)
987 } catch let error as LaTeXExport.Unsupported {
988 throw LaTeXExport.Unsupported(reason: "Can't export \((path as NSString).lastPathComponent) to LaTeX: \(error.reason)")
989 }
986 } 990 }
987 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension 991 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
988 return HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, bodyOnly: bodyOnly, codeStyle: codeStyle, language: OrgPreferences.exportLanguage()) 992 return HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, bodyOnly: bodyOnly, codeStyle: codeStyle, language: OrgPreferences.exportLanguage())
Sources/OrgstarMobile/EditorScreen.swift +1
@@ -306,6 +306,7 @@ struct EditorScreen: View {
306 .onChange(of: session.lastError) { _, error in 306 .onChange(of: session.lastError) { _, error in
307 if let error { message = error; session.lastError = nil } 307 if let error { message = error; session.lastError = nil }
308 } 308 }
309 .onReceive(NotificationCenter.default.publisher(for: OrgExport.refused)) { message = $0.object as? String }
309 .onAppear(perform: start) 310 .onAppear(perform: start)
310 // A pane command moved focus here. 311 // A pane command moved focus here.
311 .onChange(of: isFocused) { 312 .onChange(of: isFocused) {
Sources/OrgstarMobile/ExportMenu.swift +13 −1
@@ -60,6 +60,10 @@ struct OrgExport: Transferable {
60 .lastPathComponent 60 .lastPathComponent
61 } 61 }
62 62
63 /// Posted with the message, for the screen's message line, when the LaTeX export refuses
64 /// the file: the share sheet shows no reason.
65 static let refused = Notification.Name("OrgExportRefused")
66
63 static var transferRepresentation: some TransferRepresentation { 67 static var transferRepresentation: some TransferRepresentation {
64 FileRepresentation(exportedContentType: .html) { try await $0.write() } 68 FileRepresentation(exportedContentType: .html) { try await $0.write() }
65 .exportingCondition { $0.format == .html } 69 .exportingCondition { $0.format == .html }
@@ -93,7 +97,15 @@ struct OrgExport: Transferable {
93 case .markdown: 97 case .markdown:
94 try MarkdownExport.document(text, settings: settings, path: path).write(to: url, atomically: true, encoding: .utf8) 98 try MarkdownExport.document(text, settings: settings, path: path).write(to: url, atomically: true, encoding: .utf8)
95 case .latex: 99 case .latex:
96 try LaTeXExport.document(text, settings: settings, path: path, language: OrgPreferences.exportLanguage(), file: true).write(to: url, atomically: true, encoding: .utf8) 100 let content: String
101 do {
102 content = try LaTeXExport.document(text, settings: settings, path: path, language: OrgPreferences.exportLanguage(), file: true)
103 } catch let error as LaTeXExport.Unsupported {
104 let message = "Can't export to LaTeX: \(error.reason)"
105 await MainActor.run { NotificationCenter.default.post(name: Self.refused, object: message) }
106 throw error
107 }
108 try content.write(to: url, atomically: true, encoding: .utf8)
97 case .icalendar: 109 case .icalendar:
98 try ICalendarFiles.export(self.text, path: path, settings: settings, options: OrgPreferences.icalendarOptions(), 110 try ICalendarFiles.export(self.text, path: path, settings: settings, options: OrgPreferences.icalendarOptions(),
99 subtree: subtree, destination: url) 111 subtree: subtree, destination: url)
Sources/OrgstarMobile/ReaderScreen.swift +1
@@ -121,6 +121,7 @@ struct ReaderScreen: View {
121 .onChange(of: pane?.path) { loadFolds() } 121 .onChange(of: pane?.path) { loadFolds() }
122 .onChange(of: pane?.editVersion) { loadFolds() } 122 .onChange(of: pane?.editVersion) { loadFolds() }
123 .onChange(of: model.settingsVersion) { loadFolds() } 123 .onChange(of: model.settingsVersion) { loadFolds() }
124 .onReceive(NotificationCenter.default.publisher(for: OrgExport.refused)) { message = $0.object as? String }
124 } 125 }
125 126
126 // MARK: - Content 127 // MARK: - Content
docs/manual/guide/12-export.org +2 −2
@@ -232,9 +232,9 @@ It reads:
232| =#+LATEX_COMPILER:= | =pdflatex= (the default), =xelatex= or =lualatex=: the packages for that engine | 232| =#+LATEX_COMPILER:= | =pdflatex= (the default), =xelatex= or =lualatex=: the packages for that engine |
233| =#+ATTR_LATEX:= | On tables (=:environment=, =:align=, =:width=, =:float=, =:placement=, =:center=, =:font=, =:caption=, =:options=), images (=:width=, =:height=, =:scale=, =:options=, =:float=, =:placement=, =:center=), lists, quote, example and special blocks | 233| =#+ATTR_LATEX:= | On tables (=:environment=, =:align=, =:width=, =:float=, =:placement=, =:center=, =:font=, =:caption=, =:options=), images (=:width=, =:height=, =:scale=, =:options=, =:float=, =:placement=, =:center=), lists, quote, example and special blocks |
234 234
235=#+TITLE=, =#+SUBTITLE=, =#+AUTHOR=, =#+DATE=, =#+KEYWORDS=, =#+DESCRIPTION=, =#+LANGUAGE= and =#+OPTIONS= work as in Emacs, as do the tags and =COMMENT= that leave headings out (see /Which headings are exported/). Body-only and subtree export are in the export dialog. 235=#+TITLE=, =#+SUBTITLE=, =#+AUTHOR=, =#+DATE=, =#+KEYWORDS=, =#+DESCRIPTION=, =#+LANGUAGE= and =#+OPTIONS= work as in Emacs, as do the tags and =COMMENT= that leave headings out (see /Which headings are exported/). Body-only and subtree export are in the export dialog. In a subtree export, the heading's =EXPORT_LATEX_CLASS=, =EXPORT_LATEX_CLASS_OPTIONS=, =EXPORT_LATEX_HEADER=, =EXPORT_LATEX_HEADER_EXTRA=, =EXPORT_LATEX_COMPILER=, =EXPORT_SUBTITLE=, =EXPORT_KEYWORDS=, =EXPORT_DESCRIPTION= and =EXPORT_LANGUAGE= properties replace the file's keywords.
236 236
237A file with something this export doesn't handle stops with "Can't export to LaTeX: " and what it was, rather than giving a =.tex= that differs from Emacs's: a LaTeX class other than the three, Babel or Polyglossia in the header, citations, radio targets, inline tasks, table.el tables, inline source blocks and calls, =#+CALL=, source blocks exported with their results, footnote definitions of several paragraphs, footnotes in headings, tables or item tags, =:mode math= and long tables, =UNNUMBERED= and =ALT_TITLE=, and =#+OPTIONS= items other than =toc=, =num=, =H=, =tags=, =todo=, =pri=, =^=, =tex=, =title=, =author=, =date=, =-= and =timestamp= set to something other than Org's default. A link Emacs can't resolve stops the export in both. In the download version, when Emacs is installed, such a file is exported by Emacs instead (see /Exporting through Emacs/). 237A file with something this export doesn't handle stops with "Can't export to LaTeX: " and what it was, rather than giving a =.tex= that differs from Emacs's: a LaTeX class other than the three, Babel or Polyglossia in the header, citations, radio targets, inline tasks, table.el tables, inline source blocks and calls, =#+CALL=, source blocks exported with their results, footnote definitions of several paragraphs, footnotes in headings, tables or item tags, =:mode math= and long tables, =UNNUMBERED= and =ALT_TITLE=, =tex:verbatim=, and =#+OPTIONS= items other than =toc=, =num=, =H=, =tags=, =todo=, =pri=, =^=, =tex=, =title=, =author=, =date=, =-= and =timestamp= set to something other than Org's default. A link Emacs can't resolve stops the export in both, including a link to a heading, target or named element the export leaves out. On iOS the share sheet stops and the message shows at the bottom of the screen. Publishing to LaTeX stops with the file's name in the message. In the download version, when Emacs is installed, such a file is exported by Emacs instead (see /Exporting through Emacs/).
238 238
239* Word, RTF and plain text 239* Word, RTF and plain text
240 240
docs/manual/guide/14-ios.org +1 −1
@@ -329,7 +329,7 @@ The app icon's badge counts the entries in the agenda's Overdue section that are
329 329
330* Export 330* Export
331 331
332Export (in the reader's toolbar and the editor's More menu) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, iCalendar and LaTeX, and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. 332Export (in the reader's toolbar and the editor's More menu) offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text, iCalendar and LaTeX, and Copy as Rich Text. Each opens the share sheet with a file named after the org file, which you can send to another app or keep with Save to Files. The export reads the file's setup files and follows its export keywords, as the Mac's export does. For a file the LaTeX export can't write as Emacs would, the share sheet stops and "Can't export to LaTeX: " and the reason show at the bottom of the screen.
333 333
334PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. ODT, ASCII and PDF through LaTeX aren't available on iOS. See [[file:12-export.org][Export]]. 334PDF export follows =pdf-margin=, =pdf-font= and =pdf-page-numbers= in =config.toml=, and Word files get heading styles and the file's images, as on the Mac. ODT, ASCII and PDF through LaTeX aren't available on iOS. See [[file:12-export.org][Export]].
335 335