Skip to content

Commit 7d95a91

Browse files
authored
fix: Clean up files in repo (#2963)
BREAKING CHANGE: - remove built files from git repo. - If you need to use the latest version of marked on the web you can use a cdn to get marked.min.js from npm: - `https://cdn.jsdelivr.net/npm/marked/marked.min.js`
1 parent ccc7a8f commit 7d95a91

21 files changed

+459
-8176
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
node_modules/
44
test/compiled_tests
55
public
6+
lib
67
docs/LICENSE.md
78
vuln.js
9+
man/marked.1
10+
marked.min.js

Makefile

Lines changed: 0 additions & 15 deletions
This file was deleted.

component.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

build-docs.js renamed to docs/build.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
/* global marked */
2+
import '../marked.min.js';
13
import { promises } from 'fs';
24
import { join, dirname, parse, format } from 'path';
3-
import { Marked } from './lib/marked.esm.js';
45
import { markedHighlight } from 'marked-highlight';
56
import { HighlightJS } from 'highlight.js';
67
import titleize from 'titleize';
@@ -13,7 +14,7 @@ const outputDir = join(cwd, 'public');
1314
const templateFile = join(inputDir, '_document.html');
1415
const isUppercase = str => /[A-Z_]+/.test(str);
1516
const getTitle = str => str === 'INDEX' ? '' : titleize(str.replace(/_/g, ' ')) + ' - ';
16-
const marked = new Marked(markedHighlight((code, language) => {
17+
const markedInstance = new marked.Marked(markedHighlight((code, language) => {
1718
if (!language) {
1819
return highlightAuto(code).value;
1920
}
@@ -24,28 +25,38 @@ async function init() {
2425
console.log('Cleaning up output directory ' + outputDir);
2526
await rm(outputDir, { force: true, recursive: true });
2627
await mkdir(outputDir);
28+
console.log(`Copying file ${join(inputDir, 'LICENSE.md')}`);
2729
await copyFile(join(cwd, 'LICENSE.md'), join(inputDir, 'LICENSE.md'));
30+
console.log(`Copying file ${join(outputDir, 'marked.min.js')}`);
31+
await copyFile(join(cwd, 'marked.min.js'), join(outputDir, 'marked.min.js'));
2832
const tmpl = await readFile(templateFile, 'utf8');
2933
console.log('Building markdown...');
3034
await build(inputDir, tmpl);
3135
console.log('Build complete!');
3236
}
3337

38+
const ignoredFiles = [
39+
join(cwd, 'docs', 'build.js'),
40+
join(cwd, 'docs', '.eslintrc.json'),
41+
join(cwd, 'docs', '_document.html')
42+
];
43+
3444
async function build(currentDir, tmpl) {
3545
const files = await readdir(currentDir);
3646
for (const file of files) {
3747
const filename = join(currentDir, file);
48+
if (ignoredFiles.includes(filename)) {
49+
continue;
50+
}
3851
const stats = await stat(filename);
3952
const { mode } = stats;
4053
if (stats.isDirectory()) {
41-
// console.log('Found directory ' + filename);
4254
await build(filename, tmpl);
4355
} else {
44-
// console.log('Reading file ' + filename);
4556
let html = await readFile(filename, 'utf8');
4657
const parsed = parse(filename);
4758
if (parsed.ext === '.md' && isUppercase(parsed.name)) {
48-
const mdHtml = marked.parse(html);
59+
const mdHtml = markedInstance.parse(html);
4960
html = tmpl
5061
.replace('<!--{{title}}-->', getTitle(parsed.name))
5162
.replace('<!--{{content}}-->', mdHtml);
@@ -55,7 +66,6 @@ async function build(currentDir, tmpl) {
5566
}
5667
parsed.dir = parsed.dir.replace(inputDir, outputDir);
5768
const outfile = format(parsed);
58-
// console.log('Ensure directory ' + dirname(outfile));
5969
await mkdir(dirname(outfile), { recursive: true });
6070
console.log('Writing file ' + outfile);
6171
await writeFile(outfile, html, { mode });

docs/demo/demo.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ html, body {
55
color: #333;
66
background-color: #fbfbfb;
77
height: 100%;
8+
overflow: auto;
89
}
910

1011
textarea {

0 commit comments

Comments
 (0)