-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add the includePosition option
- Loading branch information
1 parent
b504ef6
commit 3164e4f
Showing
7 changed files
with
1,049 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { simpleAst } from '../index.js' | ||
|
||
const markdown = `--- | ||
hello: world | ||
--- | ||
# Heading 1 | ||
Some text under Heading 1 | ||
Text that has (inline::variables) | ||
## Inline elements | ||
- Tana and logseq likes | ||
- embedded nodes` | ||
|
||
const ast = simpleAst(markdown, { normalize: true, includePosition: true }) | ||
|
||
console.log(JSON.stringify(ast, null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { simpleAst as sa } from './src/simpleAst.js' | ||
import { createMarkdownParser } from './src/markdown/markdownParser.js' | ||
|
||
function simpleAst ( | ||
fullText, options = { normalize: false, inlineAsArray: false }) { | ||
const defaultOptions = { | ||
normalize: false, inlineAsArray: false, includePosition: false, | ||
} | ||
|
||
function simpleAst (fullText, options = {}) { | ||
const parser = createMarkdownParser() | ||
const astNode = parser.parse(fullText) | ||
return sa({ astNode, fullText }, options) | ||
return sa({ astNode, fullText }, { ...defaultOptions, ...options }) | ||
} | ||
|
||
export { simpleAst } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Playground | ||
|
||
To run | ||
|
||
```sh | ||
npm run install | ||
``` | ||
|
||
Then | ||
|
||
```sh | ||
npm run dev | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.