1 | const marked = require('./marked');
|
2 | const babel = require('babel-core');
|
3 | const renderer = new marked.Renderer();
|
4 |
|
5 | let res = '';
|
6 |
|
7 | const id = 'comp-id-' + Math.random();
|
8 |
|
9 | renderer.code = (code, lang) => {
|
10 | res = code;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 | return `
|
21 | <div>
|
22 | <pre><code>${code}</code></pre>
|
23 | </div>`;
|
24 | }
|
25 |
|
26 | function process(source) {
|
27 | source = marked(source, {renderer: renderer});
|
28 | const res = JSON.stringify(source);
|
29 | return res;
|
30 | }
|
31 |
|
32 |
|
33 | module.exports = function(source, map){
|
34 | this.cacheable && this.cacheable();
|
35 |
|
36 | var exports = process(source);
|
37 | console.log('----------------')
|
38 | console.log(res);
|
39 | console.log('--------------')
|
40 | this.callback(null, res, map);
|
41 |
|
42 | } |
\ | No newline at end of file |