How to use the Slugger function from marked

Find comprehensive JavaScript marked.Slugger code examples handpicked from public code repositorys.

16
17
18
19
20
21
22
23
24
25

/*
 * Note that it is important to create a dedicated instance
 * as it counts occurrence of each title.
 */
const slugger = new marked.Slugger();

return headingTokens
    .map((headingToken) => {
        // text token for the content
fork icon1
star icon2
watch icon0

-1
fork icon1
star icon0
watch icon0

+ 3 other calls in file

57
58
59
60
61
62
63
64
65
66
67


// create internal links for ()[#]
renderer.link = function (href, title, text) {
    title = title || text;
    if (href === '#') {
        var slugger = new marked.Slugger();
        href = '#' + slugger.slug(text);
    }
    title = escapeHtml(title);
    return '<a href="' + href + '" title="' + title + '">' + text + '</a>';
fork icon0
star icon0
watch icon0

31
32
33
34
35
36
37
38
39
  this.token = null;
  this.options = options || marked.defaults;
  this.options.renderer = this.options.renderer;
  this.renderer = this.options.renderer;
  this.renderer.options = this.options;
  this.slugger = new marked.Slugger();

  this.docdef = Object.assign({}, defaultDocDefinition);
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file