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 {
982982 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
983983 if function == "org-md-publish-to-md" { return MarkdownExport.document(text, settings: settings, path: path, bodyOnly: bodyOnly) }
984984 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 }
986990 }
987991 let base = ((path as NSString).lastPathComponent as NSString).deletingPathExtension
988992 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 {
306306 .onChange(of: session.lastError) { _, error in
307307 if let error { message = error; session.lastError = nil }
308308 }
309 .onReceive(NotificationCenter.default.publisher(for: OrgExport.refused)) { message = $0.object as? String }
309310 .onAppear(perform: start)
310311 // A pane command moved focus here.
311312 .onChange(of: isFocused) {
Sources/OrgstarMobile/ExportMenu.swift +13 −1
@@ -60,6 +60,10 @@ struct OrgExport: Transferable {
6060 .lastPathComponent
6161 }
6262
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
6367 static var transferRepresentation: some TransferRepresentation {
6468 FileRepresentation(exportedContentType: .html) { try await $0.write() }
6569 .exportingCondition { $0.format == .html }
@@ -93,7 +97,15 @@ struct OrgExport: Transferable {
9397 case .markdown:
9498 try MarkdownExport.document(text, settings: settings, path: path).write(to: url, atomically: true, encoding: .utf8)
9599 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)
97109 case .icalendar:
98110 try ICalendarFiles.export(self.text, path: path, settings: settings, options: OrgPreferences.icalendarOptions(),
99111 subtree: subtree, destination: url)
Sources/OrgstarMobile/ReaderScreen.swift +1
@@ -121,6 +121,7 @@ struct ReaderScreen: View {
121121 .onChange(of: pane?.path) { loadFolds() }
122122 .onChange(of: pane?.editVersion) { loadFolds() }
123123 .onChange(of: model.settingsVersion) { loadFolds() }
124 .onReceive(NotificationCenter.default.publisher(for: OrgExport.refused)) { message = $0.object as? String }
124125 }
125126
126127 // MARK: - Content
docs/manual/guide/12-export.org +2 −2
@@ -232,9 +232,9 @@ It reads:
232232| =#+LATEX_COMPILER:= | =pdflatex= (the default), =xelatex= or =lualatex=: the packages for that engine |
233233| =#+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 |
234234
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.
236236
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/).
238238
239239* Word, RTF and plain text
240240
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
329329
330330* Export
331331
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.
333333
334334PDF 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]].
335335