|
@@ -3,7 +3,7 @@
|
3
|
3
|
import { ArgumentParser } from 'argparse';
|
4
|
4
|
import chokidar from 'chokidar';
|
5
|
5
|
import express, { Request, Response } from 'express';
|
6
|
|
-import Remarkable from 'remarkable';
|
|
6
|
+import marked from 'marked';
|
7
|
7
|
import WebSocket from 'ws';
|
8
|
8
|
|
9
|
9
|
import * as fs from 'fs';
|
|
@@ -12,27 +12,23 @@ import * as path from 'path';
|
12
|
12
|
import template from './template';
|
13
|
13
|
|
14
|
14
|
const parser = new ArgumentParser({
|
15
|
|
- version: '0.1.0',
|
16
|
|
- addHelp: true,
|
|
15
|
+ add_help: true,
|
17
|
16
|
description: 'Realtime Markdown preview',
|
18
|
17
|
});
|
19
|
18
|
|
20
|
|
-parser.addArgument('file');
|
21
|
|
-parser.addArgument(
|
22
|
|
- ['-p', '--port'],
|
23
|
|
- {
|
24
|
|
- defaultValue: 1729,
|
25
|
|
- help: 'The port to run on',
|
26
|
|
- type: 'int' }
|
27
|
|
-);
|
|
19
|
+parser.add_argument('file');
|
|
20
|
+parser.add_argument('-p', '--port', {
|
|
21
|
+ default: 1729,
|
|
22
|
+ help: 'The port to run on',
|
|
23
|
+ type: 'int',
|
|
24
|
+});
|
28
|
25
|
|
29
|
|
-const { file, port } = parser.parseArgs();
|
|
26
|
+const { file, port } = parser.parse_args();
|
30
|
27
|
const filepath = path.resolve(file);
|
31
|
28
|
|
32
|
29
|
const getRenderedHTML = () => {
|
33
|
|
- const md = new Remarkable();
|
34
|
30
|
const fileContents = fs.readFileSync(filepath, 'utf-8');
|
35
|
|
- return md.render(fileContents);
|
|
31
|
+ return marked(fileContents);
|
36
|
32
|
};
|
37
|
33
|
|
38
|
34
|
const wss = new WebSocket.Server({
|