@le-static/markdown-parser v1.0.1
markdown-parser
Parse a markdown string and outputs an AST.
AST
The AST contains:
The Head, it contains an optional page title and an optional css array that contains a list of used css files.
The Document is a list of lines:
Paragraph- One or more grouped linesHeader- A line prefixed with one or more#Separator- A line with only---CodeBlock- A multi line code block declared with three backtickImport- An import statement:@import path/to/fileUnorderedList- A list of lines that start with eather-,*or+OrderedList- A list of lines that start with a number followed by a.BlockQuotes- Group of lines that starts with>Integration- A block of js code that's executed on build
Head Usage
Page Title
To set the page title you can use the following snyax, It cannot be used more than once on a page.
@ Page TitleBe Statement
To set the page template, It cannot be used more than once on a page.
@be path/to/template.mdDefine Statement
A define statement can be used to set properties that are used by the template declared via the be statement.
@declare name some valueUse Statement
A use statement can be used to import style files into the page.
@use path/to/file.cssBody Usage
Paragraph
A paragraph is a group of lines that don't fit in any other category, they are automaticly separated by whitespaces and other line type.
The returned data contains a
linesfield, with a list of the paragraph lines as string.
Header
An header is defined by a line starting with one or more #.
The returned data contains the
levelof the header (alias the number of#), and the text after the#s and any whitespaces.
# Title
## Sub titleSeparator
Use to create separation between two elements.
Returns no aditional values.
---Code Block
A code block can be use to apply specific syntax or style to multiple lines of code.
Returns the
langageof the code block and it's contentlines.
Valid:
```js
console.log('Hello World!');
```Invalid:
```console.log('Hello World');```
```
console.log('Hello World');```Import
Import statements can be used to import component and place them inside the page.
Returns the path of the
fileimported.
@import path/to/component.mdUnorderedList
Unordered lists are a grouping of multiple lines starting with -, * or +.
Returns the list of
lineswithout the prefix (-,*or+).
- First Element
- Second
* Third
+ FourthOrderedList
Ordered lists are a grouping of multiple lines starting with a number suffixed by a ., the number given has no importance.
Returns the list of
lineswithout the prefix.
1. First Element
2. Second
9. ThirdBlock Quotes
Block quotes are a grouping of multiple lines stating with >.
Returns the list of
lineswithout the prefix.
> This is the inside of a
> Block Quote !Integration
Integration are a block of js, it can be a function or anything else. \ They are executed when the file is built, they can be used to generate content depending on the current state of the project.
Returns the
codeinside the block and if it's beenclosed
$|
() => 'This String will be put in place of this block'
|$