Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples with es6+ #1521

Merged
merged 1 commit into from Jul 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions docs/USING_PRO.md
@@ -1,6 +1,6 @@
## Extending Marked

To champion the single-responsibility and open/closed prinicples, we have tried to make it relatively painless to extend marked. If you are looking to add custom functionality, this is the place to start.
To champion the single-responsibility and open/closed principles, we have tried to make it relatively painless to extend marked. If you are looking to add custom functionality, this is the place to start.

<h2 id="renderer">The renderer</h2>

Expand All @@ -10,14 +10,14 @@ The renderer is...

```js
// Create reference instance
var myMarked = require('marked');
const marked = require('marked');
UziTech marked this conversation as resolved.
Show resolved Hide resolved

// Get reference
var renderer = new myMarked.Renderer();
const renderer = new marked.Renderer();
UziTech marked this conversation as resolved.
Show resolved Hide resolved

// Override function
renderer.heading = function (text, level) {
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');
const escapedText = text.toLowerCase().replace(/[^\w]+/g, '-');

return `
<h${level}>
Expand All @@ -29,7 +29,7 @@ renderer.heading = function (text, level) {
};

// Run marked
console.log(myMarked('# heading+', { renderer: renderer }));
console.log(marked('# heading+', { renderer: renderer }));
UziTech marked this conversation as resolved.
Show resolved Hide resolved
```

**Output:**
Expand Down Expand Up @@ -105,13 +105,13 @@ The parser is...
You also have direct access to the lexer and parser if you so desire.

``` js
var tokens = marked.lexer(text, options);
const tokens = marked.lexer(text, options);
console.log(marked.parser(tokens));
```

``` js
var lexer = new marked.Lexer(options);
var tokens = lexer.lex(text);
const lexer = new marked.Lexer(options);
const tokens = lexer.lex(text);
console.log(tokens);
console.log(lexer.rules);
```
Expand Down