The zero-based source offset of the first literal match, or -1.
Parameter Takes text required string
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some ideas.
```" />
<echo>{ $paper->find('ideas') }</echo>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some ideas.
```
echo $paper->find('ideas')Returns a copy with text or source of the same format inserted at a zero-based offset. With no offset, appends.
Parameter Takes content required any value at optional int
Arguments can be named: ->insert(…, at: …).
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some ideas.
```" />
<echo>{ $paper->insert(' More soon.').text }</echo>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some ideas.
```
echo $paper->insert(' More soon.').textHow many pages the PDF has.
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some \emph{ideas}.
```" />
<echo>{ $paper->pages() } pages</echo>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some \emph{ideas}.
```
echo "{ $paper->pages() } pages"# latex ->replace (search: string , replacement: string ) → latex KScript.Document Returns a copy with every literal match replaced.
Parameter Takes search required string replacement required string
Arguments can be named: ->replace(…, replacement: …).
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some ideas.
```" />
<echo>{ $paper->replace('ideas', 'plans').text }</echo>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some ideas.
```
echo $paper->replace('ideas', 'plans').text# latex ->save (path: string , as?: pdf|docx|'latex'|'markdown'|html ) KScript.Document Writes the document to a file. The filename extension (or as:) picks the format: .tex keeps the source, and .pdf, .docx, .md or .html renders the LaTeX a document part reads. With no extension, .tex.
Parameter Takes path required string as optional one of these words: pdf|docx|'latex'|'markdown'|html
Arguments can be named: ->save(…, as: …).
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some ideas.
```" />
<do>$paper->save('paper.tex')</do>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some ideas.
```
$paper->save('paper.tex')How many words the text has, not counting maths and code.
Example
.kscript XML Copy
<let name="paper" value="```latex
\section*{Introduction}
Some \emph{ideas}.
```" />
<echo>{ $paper->words() } words</echo>.kscript XML Copy
$paper = ```latex
\section*{Introduction}
Some \emph{ideas}.
```
echo "{ $paper->words() } words"