Skip to content

Commit

Permalink
Merge pull request #1521 from UziTech/es6-docs
Browse files Browse the repository at this point in the history
update examples with es6+
  • Loading branch information
joshbruce authored Jul 14, 2019
2 parents 29ac9ae + e3bb190 commit 72410a8
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions docs/USING_PRO.md
Original file line number Diff line number Diff line change
@@ -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');

// Get reference
var renderer = new myMarked.Renderer();
const renderer = new marked.Renderer();

// 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 }));
```

**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

0 comments on commit 72410a8

Please sign in to comment.