Skip to content

Commit

Permalink
Advertising unknown language as such
Browse files Browse the repository at this point in the history
  • Loading branch information
zaratan committed Nov 10, 2020
1 parent 0a14374 commit 12137f4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ const parseLang = (str) => {

const attrs = selectors.length ? selectorToAttrs(selectors) : {};
const className = classNames(
lang ? `language-${lang}` : 'language-',
lang ? `language-${lang}` : 'language-unknown',
attrs.class,
);
const { legend = '', ...restAttrs } = attrs;
Expand Down Expand Up @@ -205,7 +205,11 @@ module.exports = (options = {}) => (tree) => {
);
}, '');

const code = h('code', { className: `language-${lang}` }, u('raw', raw));
const code = h(
'code',
{ className: `language-${lang || 'unknown'}` },
u('raw', raw),
);
const pre = h(
'div',
{ className: 'remark-highlight' },
Expand Down
2 changes: 1 addition & 1 deletion test/outputs/no-lang.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<link href="./theme.css" rel="stylesheet" />
<div class="remark-highlight">
<pre class="language-"><code class="language-">hello
<pre class="language-unknown"><code class="language-unknown">hello
world
</code></pre>
</div>
2 changes: 1 addition & 1 deletion test/snapshots/index.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -1300,7 +1300,7 @@ Generated by [AVA](https://avajs.dev).
`<link href="./theme.css" rel="stylesheet" />␊
<div class="remark-highlight">␊
<pre class="language-"><code class="language-">hello␊
<pre class="language-unknown"><code class="language-unknown">hello␊
world␊
</code></pre>␊
</div>␊
Expand Down
Binary file modified test/snapshots/index.js.snap
Binary file not shown.

0 comments on commit 12137f4

Please sign in to comment.