[go: nahoru, domu]

Skip to content

Commit

Permalink
add headerPrefix option. fixes markedjs#272. misc readme fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Nov 2, 2013
1 parent 0d27d58 commit ab84e8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Minimal usage:

```js
console.log(marked('I am using __markdown__.'));
// Outputs: <p>I am using <i>markdown</i>.</p>
// Outputs: <p>I am using <strong>markdown</strong>.</p>
```

Example using all options:
Expand Down Expand Up @@ -170,6 +170,13 @@ Default: `lang-`

Set the prefix for code block classes.

### headerPrefix

Type: `String`
Default: ``

Set the prefix for header IDs.

## Access to lexer and parser

You also have direct access to the lexer and parser if you so desire.
Expand Down
4 changes: 3 additions & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,7 @@ Parser.prototype.tok = function() {
return '<h'
+ this.token.depth
+ ' id="'
+ this.options.headerPrefix
+ this.token.text.toLowerCase().replace(/[^\w]+/g, '-')
+ '">'
+ this.inline.output(this.token.text)
Expand Down Expand Up @@ -1134,7 +1135,8 @@ marked.defaults = {
silent: false,
highlight: null,
langPrefix: 'lang-',
smartypants: false
smartypants: false,
headerPrefix: ''
};

/**
Expand Down

0 comments on commit ab84e8c

Please sign in to comment.