Skip to content

Commit

Permalink
Update Lexer section in USING_PRO.md (#3317)
Browse files Browse the repository at this point in the history
  • Loading branch information
poirierlouis committed Jun 10, 2024
1 parent 9056c47 commit 481ac3b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions docs/USING_PRO.md
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,6 @@ The parser takes tokens as input and calls the renderer functions.
You also have direct access to the lexer and parser if you so desire. The lexer and parser options are the same as passed to `marked.setOptions()` except they have to be full options objects, they don't get merged with the current or default options.
``` js
const tokens = marked.lexer(markdown, options);
console.log(marked.parser(tokens, options));
Expand All @@ -582,6 +580,11 @@ console.log(marked.Lexer.rules.block); // all block level rules
console.log(marked.Lexer.rules.inline); // all inline level rules
```
Note that the lexer can be used in two different ways:
- `marked.lexer()`: this method tokenizes a string and returns its tokens. Subsequent calls to `lexer()` ignore any previous calls.
- `new marked.Lexer().lex()`: this instance tokenizes a string and returns its tokens along with any previous tokens. Subsequent calls to `lex()` accumulate tokens.
``` bash
$ node
> require('marked').lexer('> I am using marked.')
Expand Down

0 comments on commit 481ac3b

Please sign in to comment.