diff --git a/docs/etc.md b/docs/etc.md index 84c3de6..b293ad0 100644 --- a/docs/etc.md +++ b/docs/etc.md @@ -21,7 +21,7 @@ surround your code in a code fence, and it will be highlighted via ``` html <p>See this code:</p> -<pre class="sg-lang-javascript"> +<pre class="sg-language-javascript"> $(<span class='hljs-function'>function</span>() { alert(<span class='hljs-string'>"hello"</span>); }); diff --git a/examples/basic/index.html b/examples/basic/index.html index ce4522f..3d599eb 100644 --- a/examples/basic/index.html +++ b/examples/basic/index.html @@ -1,6 +1,6 @@ <!doctype html> <html class="sg"> - + <head> <meta charset="utf-8"> <title>Styledown</title> @@ -8,7 +8,7 @@ <link rel="stylesheet" href="../../data/styledown.css"> <script src="../../data/styledown.js"></script> </head> - + <body class="sg"> <div class="styleguide"> <div> @@ -47,7 +47,7 @@ <h2 id="javascript" class="sg">JavaScript</h2> <div class="sg-text"> <h3 id="jquery" class="sg">jQuery</h3> <p class="sg">This is an example with jQuery:</p> - </div><pre class="sg sg-lang-javascript sg-code"><span class="hljs-keyword">var</span> Foo = { + </div><pre class="sg sg-language-javascript sg-code"><span class="hljs-keyword">var</span> Foo = { start: <span class="hljs-function"><span class="hljs-keyword">function</span><span class="hljs-params">()</span> </span>{ <span class="hljs-comment">/* do things */</span>; alert(<span class="hljs-string">"Hi"</span>, <span class="hljs-number">2</span>); diff --git a/lib/filters.js b/lib/filters.js index 99b0bad..0806c58 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -64,13 +64,13 @@ exports.unpackExample = function (parent, pre, highlight, filePath) { parent.remove() } else { klass = parent.find('code').attr('class') - let m = klass.match(/lang-([a-z]+)/) + let m = klass.match(/language-([a-z]+)/) if (m) { /* eslint-disable-next-line prefer-destructuring */ let lang = m[1] parent.html(Hljs.highlight(lang, parent.text()).value) - parent.addClass(pre(`lang-${lang}`)) + parent.addClass(pre(`language-${lang}`)) parent.addClass(pre('code')) } } diff --git a/lib/mdconf.js b/lib/mdconf.js index 0f5028b..320a7af 100644 --- a/lib/mdconf.js +++ b/lib/mdconf.js @@ -27,7 +27,7 @@ module.exports = function(str, options){ let keys = [] let depth = 0 - toks.forEach(function(tok){ + toks.forEach((tok) => { switch (tok.type) { case 'heading': while (depth-- >= tok.depth) keys.pop() @@ -35,8 +35,10 @@ module.exports = function(str, options){ /* eslint-disable-next-line prefer-destructuring */ depth = tok.depth break - case 'list_item_start': - case 'list_item_end': + case 'list': + tok.items.forEach((item) => { + put(conf, keys, item.text, normalize) + }) break case 'text': put(conf, keys, tok.text, normalize) diff --git a/lib/utils.js b/lib/utils.js index 7a0f120..188ed1b 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -70,7 +70,7 @@ function parseTags(str) { function prefixClass(klass, prefix) { return klass.split(' ').map(function (n) { - return n.length > 0 ? (`${prefix }-${ n}`) : n + return n.length > 0 ? (`${prefix}-${n}`) : n }).join(' ') } diff --git a/package-lock.json b/package-lock.json index afae429..e22b440 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2544,9 +2544,9 @@ "dev": true }, "marked": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/marked/-/marked-0.3.1.tgz", - "integrity": "sha1-FWo7gDzFTFkpDmA1S4O6qn1mwHQ=" + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-2.0.1.tgz", + "integrity": "sha512-5+/fKgMv2hARmMW7DOpykr2iLhl0NgjyELk5yn92iE7z8Se1IS9n3UsFm86hFXIkvMBmVxki8+ckcpjBeyo/hw==" }, "mdextract": { "version": "1.0.0", diff --git a/package.json b/package.json index e9135a8..44253c4 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cheerio": "^0.22.0", "highlight.js": "^10.6.0", "js-beautify": "^1.13.5", - "marked": "^0.3.0", + "marked": "^2.0.1", "mdextract": "^1.0.0", "minimist": "^1.2.0", "prettier": "^2.2.1", diff --git a/test/prefix.js b/test/prefix.js index 3a3a614..eb14ac9 100644 --- a/test/prefix.js +++ b/test/prefix.js @@ -31,7 +31,7 @@ describe('Prefix', function() { expect(this.$('.styleguide-block')).have.length(1) }) }) - describe('inline options', function() { + describe('inline options', function() { beforeEach(function() { this.load("## Hello\n### world\nthere\n\n# Styleguide options\n\n* prefix: styleguide", { head: '' diff --git a/test/syntax.js b/test/syntax.js index 2ca5620..fff0b1d 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -15,7 +15,7 @@ describe('Syntax highlight', function() { expect(this.$).have.selector('pre .hljs-name') }) it('set correct pre class', function() { - expect(this.$).have.selector('pre.sg-lang-html') + expect(this.$).have.selector('pre.sg-language-html') }) }) describe('examples', function() {