Word export and table CSV/TSV import and export on iOS !279

merged merged by cmc on 2026-10-11 12:59 UTC · krz/orgstar:issue-36 into main

8 files changed, +221 −40

Layout: unified · split

Sources/OrgApp/DocxWriter.swift +79 −32
@@ -1,13 +1,24 @@
1import Foundation
12#if os(macOS)
23import AppKit
3import Foundation
4typealias DocxFont = NSFont
5typealias DocxColor = NSColor
6#else
7import UIKit
8typealias DocxFont = UIFont
9typealias DocxColor = UIColor
10#endif
411
512/// Word's `.docx` from styled text: paragraphs with their runs' fonts, colors and links, and
6/// tables from the text's table blocks, which the system's own writer leaves out.
13/// tables from the text's table blocks, which the system's own writer leaves out. iOS's HTML
14/// import keeps no tables, so there `tables` holds them, each standing for a paragraph that is
15/// its `marker` alone.
716enum DocxWriter {
8 static func data(from text: NSAttributedString) -> Data {
17 static func marker(_ index: Int) -> String { "\u{E000}\(index)\u{E001}" }
18
19 static func data(from text: NSAttributedString, tables: [String] = []) -> Data {
920 var links: [String] = []
10 let body = paragraphs(text, links: &links)
21 let body = paragraphs(text, tables: tables, links: &links)
1122 let document = """
1223 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
1324 <w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" \
@@ -42,33 +53,49 @@ enum DocxWriter {
4253 }
4354
4455 /// Paragraphs in order, consecutive ones in the same table gathered into `<w:tbl>`.
45 private static func paragraphs(_ text: NSAttributedString, links: inout [String]) -> String {
56 /// A `<w:tbl>` of rows of cells, each cell its paragraphs.
57 static func table(_ rows: [[String]], columns: Int) -> String {
58 var out = "<w:tbl><w:tblPr><w:tblBorders>" + ["top", "left", "bottom", "right", "insideH", "insideV"].map {
59 "<w:\($0) w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"A0A0A0\"/>"
60 }.joined() + "</w:tblBorders><w:tblCellMar><w:left w:w=\"100\" w:type=\"dxa\"/><w:right w:w=\"100\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr>"
61 out += "<w:tblGrid>" + String(repeating: "<w:gridCol/>", count: columns) + "</w:tblGrid>"
62 for row in rows {
63 out += "<w:tr>"
64 for column in 0..<columns {
65 out += "<w:tc><w:tcPr/>" + (column < row.count && !row[column].isEmpty ? row[column] : "<w:p/>") + "</w:tc>"
66 }
67 out += "</w:tr>"
68 }
69 return out + "</w:tbl>"
70 }
71
72 private static func paragraphs(_ text: NSAttributedString, tables: [String], links: inout [String]) -> String {
4673 let string = text.string as NSString
4774 var out = ""
75 #if os(macOS)
4876 var table: (block: NSTextTable, cells: [[Int: [String]]])?
4977 func flushTable() {
5078 guard let current = table else { return }
51 out += "<w:tbl><w:tblPr><w:tblBorders>" + ["top", "left", "bottom", "right", "insideH", "insideV"].map {
52 "<w:\($0) w:val=\"single\" w:sz=\"4\" w:space=\"0\" w:color=\"A0A0A0\"/>"
53 }.joined() + "</w:tblBorders><w:tblCellMar><w:left w:w=\"100\" w:type=\"dxa\"/><w:right w:w=\"100\" w:type=\"dxa\"/></w:tblCellMar></w:tblPr>"
5479 let columns = max(current.block.numberOfColumns, current.cells.map { ($0.keys.max() ?? 0) + 1 }.max() ?? 1)
55 out += "<w:tblGrid>" + String(repeating: "<w:gridCol/>", count: columns) + "</w:tblGrid>"
56 for row in current.cells {
57 out += "<w:tr>"
58 for column in 0..<columns {
59 out += "<w:tc><w:tcPr/>" + (row[column]?.joined() ?? "<w:p/>") + "</w:tc>"
60 }
61 out += "</w:tr>"
62 }
63 out += "</w:tbl>"
80 out += Self.table(current.cells.map { row in (0..<columns).map { row[$0]?.joined() ?? "" } }, columns: columns)
6481 table = nil
6582 }
83 #else
84 func flushTable() {}
85 #endif
6686 var location = 0
6787 while location < string.length {
6888 let range = string.paragraphRange(for: NSRange(location: location, length: 0))
6989 location = NSMaxRange(range)
90 let line = string.substring(with: range).trimmingCharacters(in: .whitespacesAndNewlines)
91 if let index = tables.indices.first(where: { line == marker($0) }) {
92 flushTable()
93 out += tables[index]
94 continue
95 }
7096 let style = text.attribute(.paragraphStyle, at: range.location, effectiveRange: nil) as? NSParagraphStyle
7197 let paragraph = self.paragraph(text, range, style, links: &links)
98 #if os(macOS)
7299 if let cell = style?.textBlocks.compactMap({ $0 as? NSTextTableBlock }).last {
73100 if table?.block !== cell.table {
74101 flushTable()
@@ -76,10 +103,11 @@ enum DocxWriter {
76103 }
77104 while table!.cells.count <= cell.startingRow { table!.cells.append([:]) }
78105 table!.cells[cell.startingRow][cell.startingColumn, default: []].append(paragraph)
79 } else {
80 flushTable()
81 out += paragraph
106 continue
82107 }
108 #endif
109 flushTable()
110 out += paragraph
83111 }
84112 flushTable()
85113 return out
@@ -118,18 +146,18 @@ enum DocxWriter {
118146
119147 private static func run(_ piece: String, _ attributes: [NSAttributedString.Key: Any]) -> String {
120148 var properties = ""
121 if let font = attributes[.font] as? NSFont {
122 let traits = font.fontDescriptor.symbolicTraits
123 let name = traits.contains(.monoSpace) ? "Menlo" : (font.familyName ?? "Helvetica Neue")
149 if let font = attributes[.font] as? DocxFont {
150 let traits = self.traits(font)
151 let name = traits.mono ? "Menlo" : traits.family
124152 properties += "<w:rFonts w:ascii=\"\(escape(name))\" w:hAnsi=\"\(escape(name))\" w:cs=\"\(escape(name))\"/>"
125 if traits.contains(.bold) { properties += "<w:b/>" }
126 if traits.contains(.italic) { properties += "<w:i/>" }
153 if traits.bold { properties += "<w:b/>" }
154 if traits.italic { properties += "<w:i/>" }
127155 properties += "<w:sz w:val=\"\(Int((font.pointSize * 2).rounded()))\"/>"
128156 }
129 if let color = (attributes[.foregroundColor] as? NSColor)?.usingColorSpace(.sRGB) { properties += "<w:color w:val=\"\(hex(color))\"/>" }
157 if let color = (attributes[.foregroundColor] as? DocxColor).flatMap(rgba) { properties += "<w:color w:val=\"\(hex(color))\"/>" }
130158 if (attributes[.underlineStyle] as? Int ?? 0) != 0 { properties += "<w:u w:val=\"single\"/>" }
131159 if (attributes[.strikethroughStyle] as? Int ?? 0) != 0 { properties += "<w:strike/>" }
132 if let background = (attributes[.backgroundColor] as? NSColor)?.usingColorSpace(.sRGB), background.alphaComponent > 0.05 {
160 if let background = (attributes[.backgroundColor] as? DocxColor).flatMap(rgba), background.a > 0.05 {
133161 properties += "<w:shd w:val=\"clear\" w:color=\"auto\" w:fill=\"\(hex(background))\"/>"
134162 }
135163 if let offset = attributes[.baselineOffset] as? Double, offset != 0 { properties += "<w:vertAlign w:val=\"\(offset > 0 ? "superscript" : "subscript")\"/>" }
@@ -151,11 +179,31 @@ enum DocxWriter {
151179 return "<w:r><w:rPr>\(properties)</w:rPr>\(content)</w:r>"
152180 }
153181
182 private static func traits(_ font: DocxFont) -> (bold: Bool, italic: Bool, mono: Bool, family: String) {
183 let traits = font.fontDescriptor.symbolicTraits
184 #if os(macOS)
185 return (traits.contains(.bold), traits.contains(.italic), traits.contains(.monoSpace), font.familyName ?? "Helvetica Neue")
186 #else
187 return (traits.contains(.traitBold), traits.contains(.traitItalic), traits.contains(.traitMonoSpace), font.familyName)
188 #endif
189 }
190
191 /// The color's sRGB components and alpha.
192 private static func rgba(_ color: DocxColor) -> (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat)? {
193 #if os(macOS)
194 guard let c = color.usingColorSpace(.sRGB) else { return nil }
195 return (c.redComponent, c.greenComponent, c.blueComponent, c.alphaComponent)
196 #else
197 var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
198 guard color.getRed(&r, green: &g, blue: &b, alpha: &a) else { return nil }
199 return (r, g, b, a)
200 #endif
201 }
202
154203 /// `#rrggbb` of the color laid on white paper: Word has no transparency.
155 private static func hex(_ color: NSColor) -> String {
156 let a = color.alphaComponent
157 func on(_ c: CGFloat) -> Int { Int(((c * a + (1 - a)) * 255).rounded()) }
158 return String(format: "%02X%02X%02X", on(color.redComponent), on(color.greenComponent), on(color.blueComponent))
204 private static func hex(_ color: (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat)) -> String {
205 func on(_ c: CGFloat) -> Int { Int(((c * color.a + (1 - color.a)) * 255).rounded()) }
206 return String(format: "%02X%02X%02X", on(color.r), on(color.g), on(color.b))
159207 }
160208
161209 static func escape(_ s: String) -> String {
@@ -208,4 +256,3 @@ struct ZipWriter {
208256 return c ^ 0xFFFFFFFF
209257 }
210258}
211#endif
Sources/OrgApp/RichTextExport.swift +45
@@ -49,6 +49,51 @@ public enum RichTextExport {
4949 }
5050 #endif
5151
52 /// The HTML export as Word's `.docx`, tables included.
53 public static func docx(html: String, directory: URL?) throws -> Data {
54 #if os(macOS)
55 return try docx(attributed(html: html, directory: directory))
56 #else
57 let (page, tables) = extractingTables(html)
58 return DocxWriter.data(from: try attributed(html: page, directory: directory), tables: tables)
59 #endif
60 }
61
62 /// `html` with each `<table>` replaced by a paragraph holding `DocxWriter.marker`, and the
63 /// tables as Word XML, header cells bold.
64 static func extractingTables(_ html: String) -> (html: String, tables: [String]) {
65 var tables: [String] = []
66 var out = ""
67 var rest = Substring(html)
68 while let match = rest.firstMatch(of: #/(?is)<table\b.*?</table>/#) {
69 out += rest[..<match.range.lowerBound]
70 var rows: [[String]] = []
71 for row in match.0.matches(of: #/(?is)<tr\b[^>]*>(.*?)</tr>/#) {
72 rows.append(row.1.matches(of: #/(?is)<t([hd])\b[^>]*>(.*?)</t[hd]>/#).map { cell in
73 let text = decode(String(cell.2).replacing(#/(?s)<[^>]*>/#, with: "")).trimmingCharacters(in: .whitespacesAndNewlines)
74 guard !text.isEmpty else { return "" }
75 return "<w:p><w:pPr></w:pPr><w:r><w:rPr>\(cell.1.lowercased() == "h" ? "<w:b/>" : "")</w:rPr><w:t xml:space=\"preserve\">\(DocxWriter.escape(text))</w:t></w:r></w:p>"
76 })
77 }
78 out += "<p>\(DocxWriter.marker(tables.count))</p>"
79 tables.append(DocxWriter.table(rows, columns: rows.map(\.count).max() ?? 1))
80 rest = rest[match.range.upperBound...]
81 }
82 return (out + rest, tables)
83 }
84
85 /// HTML character references.
86 static func decode(_ s: String) -> String {
87 var out = s
88 for (entity, character) in [("&lt;", "<"), ("&gt;", ">"), ("&quot;", "\""), ("&#39;", "'"), ("&nbsp;", "\u{A0}")] {
89 out = out.replacingOccurrences(of: entity, with: character)
90 }
91 out = out.replacing(#/&#(x?)([0-9a-fA-F]+);/#) { m in
92 UInt32(m.2, radix: m.1.isEmpty ? 10 : 16).flatMap(Unicode.Scalar.init).map { String(Character($0)) } ?? String(m.0)
93 }
94 return out.replacingOccurrences(of: "&amp;", with: "&")
95 }
96
5297 /// The HTML export as RTF.
5398 public static func rtf(html: String, directory: URL?) throws -> Data {
5499 try rtf(attributed(html: html, directory: directory))
Sources/OrgstarMobile/EditorScreen.swift +63
@@ -4,6 +4,7 @@ import OrgCore
44import OrgDocument
55import SwiftUI
66import UIKit
7import UniformTypeIdentifiers
78
89/// Editing a file: the text with Org's folding and styling, a bar of Org keys over the keyboard,
910/// and every command in a palette. The editor is the open file's live state, so autosave and
@@ -39,6 +40,11 @@ struct EditorScreen: View {
3940 }
4041
4142 /// One sheet at a time: two presenters on this screen interfere.
43 /// `org-table-import`'s file picker is up.
44 @State private var importingTable = false
45 /// The table at the caret, for `org-table-export`'s save dialog.
46 @State private var exportedTable: TableFile?
47
4248 enum Sheet: Identifiable {
4349 case palette, conflict, syncCopies, recovery
4450 /// `app.refile`, `app.refile.copy` or `app.refile.goto`.
@@ -82,6 +88,11 @@ struct EditorScreen: View {
8288 Button("Clock In", systemImage: "stopwatch") { editor?.run("app.clock.in") }
8389 Button("Column View", systemImage: "tablecells") { editor?.run("org.columns") }
8490 Button("Column View of File", systemImage: "tablecells.badge.ellipsis") { editor?.run("org.columns.global") }
91 Menu("Table", systemImage: "tablecells") {
92 Button("Import Table from File…", systemImage: "square.and.arrow.down") { importingTable = true }
93 Button("Export Table as CSV…", systemImage: "square.and.arrow.up") { exportTable(csv: true) }
94 Button("Export Table as TSV…", systemImage: "square.and.arrow.up") { exportTable(csv: false) }
95 }
8596 Toggle(isOn: Binding(get: { model.showMarkup }, set: { model.showMarkup = $0 })) {
8697 Label("Show Markup", systemImage: "chevron.left.forwardslash.chevron.right")
8798 }
@@ -148,6 +159,14 @@ struct EditorScreen: View {
148159 ColumnViewScreen(view: view, session: session, path: path) { offset in editor?.reveal(offset) }
149160 }
150161 }
162 .fileImporter(isPresented: $importingTable, allowedContentTypes: [.commaSeparatedText, .tabSeparatedText, .plainText]) { result in
163 importTable(result)
164 }
165 .fileExporter(isPresented: Binding(get: { exportedTable != nil }, set: { if !$0 { exportedTable = nil } }),
166 document: exportedTable, contentType: exportedTable?.type ?? .commaSeparatedText,
167 defaultFilename: exportedTable?.type == .tabSeparatedText ? "table.tsv" : "table.csv") { result in
168 if case .failure(let error) = result { message = error.localizedDescription } else { message = "Export done." }
169 }
151170 .onChange(of: session.conflict) { _, conflict in
152171 if conflict != nil, session.path == path { sheet = .conflict }
153172 }
@@ -237,6 +256,10 @@ struct EditorScreen: View {
237256 _ = session.save(path)
238257 } else if ["app.refile", "app.refile.copy", "app.refile.goto"].contains(id) {
239258 sheet = .refile(id)
259 } else if id == "app.table-import" {
260 importingTable = true
261 } else if id == "app.table-export" {
262 exportTable(csv: true)
240263 } else if id == "app.toggle-markup" {
241264 model.showMarkup.toggle()
242265 } else if MobileEditor.linkCommands.contains(id) {
@@ -258,6 +281,25 @@ struct EditorScreen: View {
258281}
259282
260283extension EditorScreen {
284 /// `org-table-import`: a TSV, CSV or space-separated file becomes a table at the caret.
285 private func importTable(_ result: Result<URL, Error>) {
286 guard case .success(let url) = result, let editor else { return }
287 let scoped = url.startAccessingSecurityScopedResource()
288 defer { if scoped { url.stopAccessingSecurityScopedResource() } }
289 guard let contents = try? String(contentsOf: url, encoding: .utf8) else { return message = "Can't read \(url.lastPathComponent)" }
290 _ = editor.perform(ImportTable(contents: contents))
291 }
292
293 /// `org-table-export` of the table at the caret, as CSV or TSV.
294 private func exportTable(csv: Bool) {
295 guard let editor else { return }
296 let context = editor.editContext()
297 guard let text = ImportTable.exportText(context.text, at: context.caret, path: csv ? "table.csv" : "table.tsv") else {
298 return message = "No table at point"
299 }
300 exportedTable = TableFile(text: text, type: csv ? .commaSeparatedText : .tabSeparatedText)
301 }
302
261303 /// `org-refile` of the entry at the caret, to a target worked out again from the files
262304 /// now, as the agenda's Refile… does.
263305 func refile(to target: RefileTarget, keep: Bool = false) {
@@ -550,6 +592,7 @@ struct CommandPalette: View {
550592 ("org.toggle-inline-images", "Show or Hide Inline Images"), ("editor.toggle-truncate-lines", "Truncate or Wrap Long Lines"),
551593 ("org.table.toggle-column-width", "Shrink or Expand Table Column"), ("org.table.shrink", "Shrink Table Columns with Widths"),
552594 ("org.table.expand", "Expand Table Columns"),
595 ("app.table-import", "Import Table from File…"), ("app.table-export", "Export Table to File…"),
553596 ]
554597
555598 /// The commands that apply at the caret and their keys, worked out once when the palette
@@ -587,4 +630,24 @@ struct CommandPalette: View {
587630 }
588631 }
589632}
633/// A table as CSV or TSV, for the save dialog.
634struct TableFile: FileDocument {
635 static var readableContentTypes: [UTType] { [.commaSeparatedText, .tabSeparatedText] }
636 let text: String
637 let type: UTType
638
639 init(text: String, type: UTType) {
640 self.text = text
641 self.type = type
642 }
643
644 init(configuration: ReadConfiguration) throws {
645 text = configuration.file.regularFileContents.map { String(decoding: $0, as: UTF8.self) } ?? ""
646 type = configuration.contentType
647 }
648
649 func fileWrapper(configuration: WriteConfiguration) throws -> FileWrapper {
650 FileWrapper(regularFileWithContents: Data(text.utf8))
651 }
652}
590653#endif
Sources/OrgstarMobile/ExportMenu.swift +11 −4
@@ -6,17 +6,18 @@ import OrgPresentation
66import SwiftUI
77import UniformTypeIdentifiers
88
9/// A file exported as HTML, Markdown, PDF, RTF, plain text or iCalendar, written when the share
10/// sheet takes it.
9/// A file exported as HTML, Markdown, PDF, Word, RTF, plain text or iCalendar, written when the
10/// share sheet takes it.
1111struct OrgExport: Transferable {
1212 enum Format: CaseIterable {
13 case html, markdown, pdf, rtf, plainText, icalendar
13 case html, markdown, pdf, docx, rtf, plainText, icalendar
1414
1515 var name: String {
1616 switch self {
1717 case .html: "HTML"
1818 case .markdown: "Markdown"
1919 case .pdf: "PDF"
20 case .docx: "Word"
2021 case .rtf: "Rich Text (RTF)"
2122 case .plainText: "Plain Text"
2223 case .icalendar: "iCalendar"
@@ -28,6 +29,7 @@ struct OrgExport: Transferable {
2829 case .html: "html"
2930 case .markdown: "md"
3031 case .pdf: "pdf"
32 case .docx: "docx"
3133 case .rtf: "rtf"
3234 case .plainText: "txt"
3335 case .icalendar: "ics"
@@ -55,6 +57,8 @@ struct OrgExport: Transferable {
5557 .exportingCondition { $0.format == .markdown }
5658 FileRepresentation(exportedContentType: .pdf) { try await $0.write() }
5759 .exportingCondition { $0.format == .pdf }
60 FileRepresentation(exportedContentType: UTType(filenameExtension: "docx") ?? .data) { try await $0.write() }
61 .exportingCondition { $0.format == .docx }
5862 FileRepresentation(exportedContentType: .rtf) { try await $0.write() }
5963 .exportingCondition { $0.format == .rtf }
6064 FileRepresentation(exportedContentType: .plainText) { try await $0.write() }
@@ -77,6 +81,9 @@ struct OrgExport: Transferable {
7781 try MarkdownExport.document(text, settings: settings, path: path).write(to: url, atomically: true, encoding: .utf8)
7882 case .icalendar:
7983 try ICalendarFiles.export(text, path: path, settings: settings, options: OrgPreferences.icalendarOptions(), destination: url)
84 case .docx:
85 let html = HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, codeStyle: codeStyle)
86 try await RichTextExport.docx(html: html, directory: URL(fileURLWithPath: path).deletingLastPathComponent()).write(to: url, options: .atomic)
8087 case .pdf, .rtf, .plainText:
8188 let html = HTMLExport.page(text, fallbackTitle: base, settings: settings, path: path, codeStyle: codeStyle)
8289 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
@@ -91,7 +98,7 @@ struct OrgExport: Transferable {
9198 }
9299}
93100
94/// Sharing the file as HTML, Markdown, PDF, RTF, plain text or iCalendar: to another app, or saved with
101/// Sharing the file as HTML, Markdown, PDF, Word, RTF, plain text or iCalendar: to another app, or saved with
95102/// Save to Files; or copying it as rich text.
96103struct ExportMenu: View {
97104 let path: String
Sources/OrgstarMobile/MobileEditor.swift +2 −1
@@ -297,7 +297,8 @@ final class MobileEditor: NSObject, DocumentBuffer {
297297 case "org.cycle-global", "edit.undo", "edit.redo", "org.toggle-inline-images", "editor.toggle-truncate-lines": return true
298298 case "app.clock.in", "app.clock.out", "app.clock.cancel", "app.clock.goto", "app.clock.in-recent", "app.clock.in-last",
299299 "app.clock.goto-recent", "app.clock.default", "app.clock.resolve", "app.toggle-markup": return onAppCommand != nil
300 case "app.refile.goto": return onAppCommand != nil
300 case "app.refile.goto", "app.table-import": return onAppCommand != nil
301 case "app.table-export": return onAppCommand != nil && ImportTable.exportText(context.text, at: context.caret, path: "") != nil
301302 case "app.refile", "app.refile.copy": return onAppCommand != nil && Presentation.heading(containing: context.caret, in: context.tree) != nil
302303 case _ where Self.linkCommands.contains(id): return onAppCommand != nil
303304 case "org.link.open": return OpenLinkAtPoint().applies(in: context)
Tests/OrgAppTests/RichTextExportTests.swift +15
@@ -35,6 +35,21 @@ struct RichTextExportTests {
3535 #expect(font?.fontDescriptor.symbolicTraits.contains(.bold) == true)
3636 }
3737
38 /// As iOS writes Word, whose HTML import keeps no tables: the tables from the HTML.
39 @Test func wordTablesFromTheHTML() throws {
40 let (page, tables) = RichTextExport.extractingTables(Self.html)
41 #expect(tables.count == 1 && !page.contains("<table") && page.contains(DocxWriter.marker(0)))
42 #expect(tables[0].components(separatedBy: "<w:tc>").count - 1 == 4)
43 #expect(tables[0].contains("<w:b/></w:rPr><w:t xml:space=\"preserve\">Name</w:t>"))
44 #expect(tables[0].contains("<w:r><w:rPr></w:rPr><w:t xml:space=\"preserve\">1</w:t>"))
45 let data = DocxWriter.data(from: try RichTextExport.attributed(html: page, directory: nil), tables: tables)
46 let xml = String(decoding: data, as: UTF8.self)
47 #expect(xml.contains("<w:tbl>") && !xml.contains("\u{E000}"))
48 let back = try NSAttributedString(data: data, options: [:], documentAttributes: nil).string
49 #expect(back.contains("Report") && back.contains("Count") && back.contains("second"), "\(back)")
50 #expect(RichTextExport.decode("a &amp;lt; &#233;&#x41; &quot;") == "a &lt; éA \"")
51 }
52
3853 @Test func plainTextAndDarkSystemsStayReadable() throws {
3954 let text = try RichTextExport.attributed(html: Self.html, directory: nil)
4055 let plain = RichTextExport.plain(text)
docs/manual/guide/10-tables.org +4 −1
@@ -153,7 +153,10 @@ tables at full width.
153153| Import Table from File… (command palette) | =org-table-import= |
154154| Export Table to File… (command palette) | =org-table-export= |
155155
156Open the command palette with =⇧⌘P= (=M-x= in the Emacs preset, =SPC := in Doom).
156Open the command palette with =⇧⌘P= (=M-x= in the Emacs preset, =SPC := in Doom). On
157iOS, both are under More › Table in the editor, as Import Table from File…, Export Table
158as CSV… and Export Table as TSV…, and in Commands; the file comes from, and goes to, the
159Files app.
157160
158161Import asks for a CSV, TSV or plain text file, inserts its contents at the caret on a
159162line of its own, and converts them to a table with the separator guessed as for a
docs/manual/guide/12-export.org +2 −2
@@ -43,7 +43,7 @@ The dialog remembers the format and the *Open after export* setting.
4343
4444** On iOS
4545
46The Export menu offers HTML, Markdown, PDF, Rich Text (RTF), Plain Text and iCalendar, and Copy as Rich Text. It is under More in the editor, and in the toolbar in the reader. Choosing one opens the share sheet with the exported file, named after the Org file or its =#+EXPORT_FILE_NAME:=. Send it to another app, or use Save to Files to keep it. The export is the same as on the Mac. Word, LaTeX, ODT, ASCII and PDF through LaTeX are not available on iOS, nor are the agenda-file iCalendar exports; RTF opens in Word and Pages.
46The Export menu offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text and iCalendar, and Copy as Rich Text. It is under More in the editor, and in the toolbar in the reader. Choosing one opens the share sheet with the exported file, named after the Org file or its =#+EXPORT_FILE_NAME:=. Send it to another app, or use Save to Files to keep it. The export is the same as on the Mac. LaTeX, ODT, ASCII and PDF through LaTeX are not available on iOS, nor are the agenda-file iCalendar exports.
4747
4848* HTML export
4949
@@ -212,7 +212,7 @@ For typeset output with LaTeX's classes and packages, use Export to PDF with Ema
212212
213213* Word, RTF and plain text
214214
215Export to Word, Export to RTF and Export to Plain Text make the HTML export into a document of that kind, as the system reads HTML: headings, emphasis, links, colored keywords and code, lists, and tables. Word files (=.docx=) are written by orgstar itself, so tables come through as Word tables; RTF keeps them too. Plain text is the same text without its styles: list bullets and table cells are kept, separated by tabs. Fonts are Helvetica Neue for text and Menlo for code, and the colors are the light ones. Images are not included.
215Export to Word, Export to RTF and Export to Plain Text make the HTML export into a document of that kind, as the system reads HTML: headings, emphasis, links, colored keywords and code, lists, and tables. Word files (=.docx=) are written by orgstar itself, so tables come through as Word tables; RTF keeps them too on the Mac. On iOS, where the system's HTML reader keeps no tables, Word's tables are made from the HTML export's tables, with header cells bold and the cells' text without its styles; RTF and plain text there have the cells' text but no table. Plain text is the same text without its styles: list bullets and table cells are kept, separated by tabs. Fonts are Helvetica Neue for text and Menlo for code, and the colors are the light ones. Images are not included.
216216
217217For Org's own ASCII layout, with underlined headings and drawn tables, use Export to Plain Text with Emacs.
218218