src/iwork/doctext

Search:
Group by:
Source   Edit  

reading-order text extraction: every piece of text a document holds - headers, body, footers, text boxes, presenter notes, table cells - as one ordered sequence of labeled blocks. getText in the top-level module joins them into a single string for search and indexing.

Example: cmd: -r:off

import src/iwork/doctext
import iwork
let doc = openDocument("report.pages")
for blk in doc.textBlocks:
  echo blk.kind, " ", blk.section, ": ", blk.text

Types

TextBlock = object
  kind*: TextBlockKind
  section*: string           ## "slide 3", the sheet name, or "" when there's none
  text*: string              ## the text itself, trimmed
one piece of document text with its origin Source   Edit  
TextBlockKind = enum
  tbTitle,                  ## a slide title, sheet name, or table name
  tbBody,                   ## body text: pages paragraphs, keynote slide text
  tbHeader,                 ## page header
  tbFooter,                 ## page footer
  tbTextBox,                ## a floating text box on a page or sheet
  tbNotes,                  ## keynote presenter notes
  tbTableRow                 ## one table row, cells joined with tabs
where a block of text sits in the document Source   Edit  

Procs

proc textBlocks(idx: ObjectIndex; kind: DocKind): seq[TextBlock] {.
    ...raises: [IworkFormatError, KeyError, Exception], tags: [RootEffect],
    forbids: [].}
every block of text in the document, in reading order Source   Edit