|
3 | 3 | This is normal text in markdown. Keep it. |
4 | 4 |
|
5 | 5 | <!-- docs CODE src='../local-code-file.js' syntax='js' --> |
6 | | -```js |
7 | | -const html = { |
8 | | - tags: [ |
9 | | - '<!--', |
10 | | - '-->' |
11 | | - ], |
12 | | - pattern: [ |
13 | | - '<!-{2,}', |
14 | | - '-{2,}>' // '-->' |
15 | | - ], |
16 | | -} |
17 | | - |
18 | | -module.exports.run = () => { |
19 | | - const time = new Date() |
20 | | - console.log(`Your cron ran ${time}`) |
21 | | -} |
22 | | -``` |
| 6 | + |
23 | 7 | <!-- /docs --> |
24 | 8 |
|
25 | 9 | <!-- docs CODE src='../local-code-file-lines.js' syntax='js' lines='4-5' --> |
26 | | -```js |
27 | | - const baz = 'foobar' |
28 | | - console.log(`Hello ${baz}`) |
29 | | -``` |
| 10 | + |
30 | 11 | <!-- /docs --> |
31 | 12 |
|
32 | 13 | <!-- docs CODE src=https://raw.githubusercontent.com/DavidWells/awesome-stoicism/master/scripts/generate.js --> |
33 | | -```js |
34 | | -const fs = require('fs') |
35 | | -const path = require('path') |
36 | | -const markdownMagic = require('markdown-magic') |
37 | | - |
38 | | -const MARKDOWN_PATH = path.join(__dirname, '..', 'README.md') |
39 | | -const QUOTES_PATH = path.join(__dirname, '..', 'quotes.json') |
40 | | -const QUOTES = JSON.parse(fs.readFileSync(QUOTES_PATH, 'utf8')) |
41 | | - |
42 | | -const mdConfig = { |
43 | | - transforms: { |
44 | | - /* Usage example in markdown: |
45 | | - <!-- AUTO-GENERATED-CONTENT:START (GENERATE_QUOTE_LIST)--> |
46 | | - quote will be generated here |
47 | | - <!-- AUTO-GENERATED-CONTENT:END --> |
48 | | - */ |
49 | | - GENERATE_QUOTE_LIST: function(content, options) { |
50 | | - let md = '' |
51 | | - QUOTES.sort(sortByAuthors).forEach((data) => { |
52 | | - md += `- **${data.author}** ${data.quote}\n` |
53 | | - }) |
54 | | - return md.replace(/^\s+|\s+$/g, '') |
55 | | - } |
56 | | - } |
57 | | -} |
58 | | - |
59 | | -/* Utils functions */ |
60 | | -function sortByAuthors(a, b) { |
61 | | - const aName = a.author.toLowerCase() |
62 | | - const bName = b.author.toLowerCase() |
63 | | - return aName.localeCompare(bName) |
64 | | -} |
65 | | - |
66 | | -markdownMagic(MARKDOWN_PATH, mdConfig, () => { |
67 | | - console.log('quotes', QUOTES.length) |
68 | | - console.log('Docs updated!') |
69 | | -}) |
70 | | -``` |
| 14 | + |
71 | 15 | <!-- /docs --> |
72 | 16 |
|
73 | 17 | <!-- docs |
74 | 18 | CODE |
75 | 19 | src=https://raw.githubusercontent.com/DavidWells/awesome-stoicism/master/package.json |
76 | 20 | lines=3-4 |
77 | 21 | --> |
78 | | -```json |
79 | | - "private": true, |
80 | | - "version": "1.0.0", |
81 | | -``` |
| 22 | + |
82 | 23 | <!-- /docs --> |
83 | 24 |
|
84 | 25 | <!-- docs CODE src='../local-code-file-lines.js' syntax='js' lines='4-5' --> |
85 | | -```js |
86 | | - const baz = 'foobar' |
87 | | - console.log(`Hello ${baz}`) |
88 | | -``` |
| 26 | + |
89 | 27 | <!-- /docs --> |
90 | 28 |
|
91 | 29 | <!-- docs (CODE:src=../local-code-file.js&syntax=js) --> |
92 | | -```js |
93 | | -const html = { |
94 | | - tags: [ |
95 | | - '<!--', |
96 | | - '-->' |
97 | | - ], |
98 | | - pattern: [ |
99 | | - '<!-{2,}', |
100 | | - '-{2,}>' // '-->' |
101 | | - ], |
102 | | -} |
103 | | - |
104 | | -module.exports.run = () => { |
105 | | - const time = new Date() |
106 | | - console.log(`Your cron ran ${time}`) |
107 | | -} |
108 | | -``` |
| 30 | + |
109 | 31 | <!-- /docs --> |
110 | 32 |
|
111 | 33 | <!-- docs (CODE:src=../local-code-file-lines.js&syntax=js&lines=4-5) --> |
112 | | -```js |
113 | | - const baz = 'foobar' |
114 | | - console.log(`Hello ${baz}`) |
115 | | -``` |
| 34 | + |
116 | 35 | <!-- /docs --> |
117 | 36 |
|
118 | 37 | <!-- docs (CODE:src=https://raw.githubusercontent.com/DavidWells/awesome-stoicism/master/scripts/generate.js) --> |
119 | | -```js |
120 | | -const fs = require('fs') |
121 | | -const path = require('path') |
122 | | -const markdownMagic = require('markdown-magic') |
123 | | - |
124 | | -const MARKDOWN_PATH = path.join(__dirname, '..', 'README.md') |
125 | | -const QUOTES_PATH = path.join(__dirname, '..', 'quotes.json') |
126 | | -const QUOTES = JSON.parse(fs.readFileSync(QUOTES_PATH, 'utf8')) |
127 | | - |
128 | | -const mdConfig = { |
129 | | - transforms: { |
130 | | - /* Usage example in markdown: |
131 | | - <!-- AUTO-GENERATED-CONTENT:START (GENERATE_QUOTE_LIST)--> |
132 | | - quote will be generated here |
133 | | - <!-- AUTO-GENERATED-CONTENT:END --> |
134 | | - */ |
135 | | - GENERATE_QUOTE_LIST: function(content, options) { |
136 | | - let md = '' |
137 | | - QUOTES.sort(sortByAuthors).forEach((data) => { |
138 | | - md += `- **${data.author}** ${data.quote}\n` |
139 | | - }) |
140 | | - return md.replace(/^\s+|\s+$/g, '') |
141 | | - } |
142 | | - } |
143 | | -} |
144 | | - |
145 | | -/* Utils functions */ |
146 | | -function sortByAuthors(a, b) { |
147 | | - const aName = a.author.toLowerCase() |
148 | | - const bName = b.author.toLowerCase() |
149 | | - return aName.localeCompare(bName) |
150 | | -} |
151 | | - |
152 | | -markdownMagic(MARKDOWN_PATH, mdConfig, () => { |
153 | | - console.log('quotes', QUOTES.length) |
154 | | - console.log('Docs updated!') |
155 | | -}) |
156 | | -``` |
157 | 38 | <!-- /docs --> |
158 | 39 |
|
159 | 40 | <!-- docs (CODE:src=https://raw.githubusercontent.com/DavidWells/awesome-stoicism/master/package.json&lines=3-4) --> |
160 | | -```json |
161 | | - "private": true, |
162 | | - "version": "1.0.0", |
163 | | -``` |
| 41 | + |
164 | 42 | <!-- /docs --> |
165 | 43 |
|
166 | 44 | This is normal text in markdown. Keep it. |
0 commit comments