Documentation
¶
Overview ¶
Package markup parses the body of a KerML textual representation written in a markup language into the content blocks a document plan is built from: paragraphs and lists of inline runs, each with its byte span in the body.
Index ¶
Constants ¶
const AsciiDocEnv = "OPENSYSML_ASCIIDOCTOR"
AsciiDocEnv names the environment variable that points at the AsciiDoc converter, scripts/asciidoc/asciidoctor-json.js run by node with Asciidoctor.js installed beside it, as scripts/download-doc-pdf-toolchain.sh provisions it.
const RefScheme = "sysml:"
RefScheme is the URI scheme under which a link destination names a model element rather than a URL.
const ValuePrefix = "value:"
ValuePrefix follows RefScheme when a destination reads a feature's value rather than referencing the element.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsciiDoc ¶
type AsciiDoc struct{}
AsciiDoc parses AsciiDoc bodies through Asciidoctor.js, run as an external converter that answers the document tree as JSON: paragraphs, admonitions, bullet and numbered lists of single paragraphs, tables of text cells under a header row, stem blocks and block images, with emphasis, strong, monospaced, `stem:[…]`, links, `<<xref>>`, `sysml:ref[…]` and `sysml:value[…]` inline.
type Block ¶
type Block struct {
Kind BlockKind
// Runs are a paragraph's inline runs.
Runs []Run
// Items are a list's items.
Items []Item
// Ordered is true for a numbered list.
Ordered bool
// Caption titles a table, formula or image.
Caption string
// ColumnLabels head a table's columns and ColumnWidths size them relative
// to one another (empty for automatic widths).
ColumnLabels []string
ColumnWidths []int
// Rows are a table's body rows, one text cell per column.
Rows []TableRow
// Source is a formula's LaTeX.
Source string
// Location and Alt are an image's file and alternative text.
Location string
Alt string
// Level, Title and ID are a heading's level (1 the outermost), plain
// text and explicit anchor (empty when the markup gives none).
Level int
Title string
ID string
Span Span
}
Block is one content block of a body.
type BlockKind ¶
type BlockKind string
BlockKind classifies a content block.
const ( // BlockParagraph is a paragraph of inline runs. BlockParagraph BlockKind = "paragraph" // BlockList is a bullet or numbered list whose items are inline runs. BlockList BlockKind = "list" // BlockTable is a table of text cells under a header row. BlockTable BlockKind = "table" // BlockFormula is displayed mathematics: Source is LaTeX. BlockFormula BlockKind = "formula" // BlockImage is a figure read from a file: Location names it. BlockImage BlockKind = "image" // BlockHeading opens a section: Level is the markup's heading level and // Title its plain text, ID the explicit anchor the markup gave it. BlockHeading BlockKind = "heading" )
type Markdown ¶
type Markdown struct{}
Markdown parses CommonMark bodies: paragraphs and tight or loose lists of single paragraphs, with emphasis, strong emphasis, code spans, links, autolinks, `sysml:` references and `$…$` mathematics inline. No GFM extension is enabled, so tables, footnotes, strikethrough and task lists read as the paragraphs CommonMark makes of them.
type Parser ¶
type Parser interface {
// Language is the language string the parser serves, in canonical spelling.
Language() string
// Parse maps a body onto content blocks, or fails with an
// *UnsupportedConstructError for a construct no content block carries.
Parse(body string) ([]Block, error)
// External reports whether Parse runs a converter of the host rather than
// code of this process, so that what it answers is the host's.
External() bool
}
Parser parses bodies written in one markup language.
type RunKind ¶
type RunKind string
RunKind classifies an inline run.
const ( // RunText is styled prose. RunText RunKind = "text" // RunLink is a hyperlink: Text labels Destination, a URL. RunLink RunKind = "link" // RunRef is a model reference: Text labels Destination, the target's // notation after the `sysml:` scheme; an empty Text asks for the default label. RunRef RunKind = "ref" // RunValue is a model value: Destination is the feature's notation after // the `sysml:value:` scheme and Text the label the value follows, if any. RunValue RunKind = "value" // RunMath is inline mathematics: Text is LaTeX source. RunMath RunKind = "math" )
type ToolError ¶
ToolError reports the converter missing or failing: Tool is the converter looked for, Named whether EnvVar named it (else it is the default looked up on PATH), Missing whether it was not found, Detail what else was observed.
type UnsupportedConstructError ¶
UnsupportedConstructError reports a markup construct no content block carries, with the line of the body it starts on (1-based).
func (*UnsupportedConstructError) Error ¶
func (e *UnsupportedConstructError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
Package markuptest stands in for the AsciiDoc converter in tests: a recorded converter answers each body it has a recording for, so the mapping is tested without node.
|
Package markuptest stands in for the AsciiDoc converter in tests: a recorded converter answers each body it has a recording for, so the mapping is tested without node. |