Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit b3be8f3

Browse files
author
Dom Harrington
committed
Add missing markdown index. Modify gitignore. No idea how it got to this state ¯\_(ツ)_/¯
1 parent aaa83de commit b3be8f3

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

packages/api-explorer/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
node_modules
22
coverage
3-
index.js
3+
dist/index.js
44
.DS_Store
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const marked = require('marked');
2+
const Emoji = require('./emojis.js').emoji;
3+
const syntaxHighlighter = require('@readme/syntax-highlighter');
4+
const sanitizer = require('./sanitizer');
5+
const renderer = require('./renderer');
6+
7+
const emojis = new Emoji();
8+
9+
module.exports = function markdown(text, opts = {}) {
10+
marked.setOptions({
11+
sanitize: true,
12+
preserveNumbering: true,
13+
renderer,
14+
emoji(emojiText) {
15+
const emoji = emojiText.replace(/[^-_+a-zA-Z0-9]/g, '').toLowerCase();
16+
if (emoji.substr(0, 3) === 'fa-') {
17+
return `<i class="fa ${emoji}"></i>`;
18+
}
19+
if (emojis.is(emoji)) {
20+
return `<img src="/img/emojis/${emoji}.png" alt=":${emoji}+:" title=":${emoji}:" class="emoji" align="absmiddle" height="20" width="20">`;
21+
}
22+
return `:${emoji}:`;
23+
},
24+
highlight(code, language) {
25+
if (!language) return undefined;
26+
return syntaxHighlighter(code, language);
27+
},
28+
gfm: true,
29+
breaks: !opts.correctnewlines,
30+
// By default we don't wanna strip any tags
31+
// so we use our sanitizer and not the built in
32+
// which just calls `escape()`
33+
sanitizer: opts.stripHtml ? undefined : sanitizer,
34+
});
35+
return marked(text);
36+
};

0 commit comments

Comments
 (0)