Methods
module:lib/compile(source, parsedopt) → {Section}
Compile a (optionally) parsed tree, replacing all Value blocks to 'compiled' subtype
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
source |
string | ||
parsed |
Section |
<optional> |
if not provided, the source is parsed |
- Source:
Returns:
- the parsed Section
- Type
- Section
module:lib/getSnippet(source, line, sizeopt) → {string}
Extract the code snippet in the given region
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
source |
string | original source |
||
line |
number | |||
size |
number |
<optional> |
1 |
- Source:
Returns:
- Type
- string
module:lib/parse(source) → {Section}
Parses the source
Parameters:
Name | Type | Description |
---|---|---|
source |
string |
- Source:
Returns:
- Type
- Section
Type Definitions
Code
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
type |
string | always 'code' |
language |
string | |
content |
string | the code block content |
line |
number | |
size |
number | number of lines |
- Source:
Section
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
type |
string | always 'section' |
content |
string | the original content |
line |
number | |
size |
number | always 1 |
name |
string | |
children |
Array.<(Section|Text|Value)> |
- Source:
Text
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
type |
string | always 'text' |
content |
string | the paragraph content |
line |
number | |
size |
number | number of lines |
- Source:
Value
Type:
- Object
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string | always 'value' |
|
content |
string |
<nullable> |
the original content, only present for the first value in the tree |
line |
number | ||
size |
number | number of lines |
|
subtype |
string | one of: 'array', 'object', 'mixin', 'js', 'compiled', 'function' |
|
elements |
Array.<Value> |
<nullable> |
present for subtype 'array' |
isUnordered |
boolean |
<nullable> |
present for subtype 'array' |
keys |
Array.<{name: string, value: Value}> |
<nullable> |
present for subtype 'object' |
base |
string |
<nullable> |
present for subtype 'mixin' |
removals |
Array.<string> |
<nullable> |
present for subtype 'mixin' |
additions |
Array.<{name: string, value: Value}> |
<nullable> |
present for subtype 'mixin' |
code |
string |
<nullable> |
present for subtype 'js' |
run |
function |
<nullable> |
present for subtype 'compiled' |
args |
string | present for subtype 'function' |
|
body |
string | present for subtype 'function' |
- Source: