2 |
3 | Text on the top right corner. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
4 | Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Luctus accumsan tortor posuere ac. Euismod elementum nisi quis eleifend quam.
5 | Hendrerit dolor magna eget est lorem ipsum dolor. Tincidunt tortor aliquam nulla facilisi cras fermentum odio eu feugiat.
6 | Quis viverra nibh cras pulvinar. Hendrerit gravida rutrum quisque non tellus.
7 | Viverra ipsum nunc aliquet bibendum.
8 | Purus ut faucibus pulvinar elementum integer enim neque volutpat ac
9 |
--------------------------------------------------------------------------------
/demo.js:
--------------------------------------------------------------------------------
1 | const fs = require('fs')
2 | const path = require('path')
3 | const markdownMagic = require('markdown-magic')
4 |
5 | const config = {
6 | transforms: {
7 | /* Match AUTO-GENERATED-CONTENT (customTransform:optionOne=hi&optionOne=DUDE) */
8 | customTransform(content, options) {
9 | console.log('original innerContent', content)
10 | console.log(options) // { optionOne: hi, optionOne: DUDE}
11 | return `This will replace all the contents of inside the comment ${options.optionOne}`
12 | },
13 | // /* Match AUTO-GENERATED-CONTENT (RENDERDOCS:path=../file.js) */
14 | // RENDERDOCS(content, options) {
15 | // const contents = fs.readFileSync(options.path, 'utf8')
16 | // const docBlocs = require('dox').parseComments(contents, { raw: true, skipSingleStar: true })
17 | // let updatedContent = ''
18 | // docBlocs.forEach((data) => {
19 | // updatedContent += `${data.description.full}\n\n`
20 | // })
21 | // return updatedContent.replace(/^\s+|\s+$/g, '')
22 | // },
23 | // pluginExample: require('./plugin-example')({ addNewLine: true }),
24 | // count: require('markdown-magic-wordcount'),
25 | // github: require('markdown-magic-github-contributors')
26 | }
27 | }
28 |
29 | const markdownPath = path.join(__dirname, 'demo.md')
30 | markdownMagic(markdownPath, config, function(err, output) {
31 | // output is array of file information
32 | console.log('FINISHED')
33 | })
34 |
--------------------------------------------------------------------------------
/svg-with-css.svg:
--------------------------------------------------------------------------------
1 |
86 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Advanced Markdown Guide
2 |
3 | [Slides -> github.com/DavidWells/advanced-markdown](https://github.com/DavidWells/advanced-markdown/)
4 |
5 | ## Table of Contents
6 |
7 |
8 | "Click to expand"
9 |
10 | - [Why markdown?](#why-markdown)
11 | - [Markdown basics](#markdown-basics)
12 | - [Advanced Formatting tips](#advanced-formatting-tips)
13 | - [`left` alignment](#left-alignment)
14 | - [`right` alignment](#right-alignment)
15 | - [`center` alignment example](#center-alignment-example)
16 | - [`collapse` Sections](#collapse-sections)
17 | - [`additional links`](#additional-links)
18 | - [Badges](#badges)
19 | - [Useful packages](#useful-packages)
20 | - [Useful utilities](#useful-utilities)
21 | - [How Serverless uses markdown](#how-serverless-uses-markdown)
22 | - [DEMO](#demo)
23 | - [Other Markdown Resources](#other-markdown-resources)
24 |
25 |
26 |
27 |
28 | ## Why markdown?
29 |
30 | Markdown is a universal doc format that is easy to write and easy to add to a version control system.
31 |
32 | - **Open** - Anyone can submit content, fix typos & update anything via pull requests
33 | - **Version control** - Roll back & see the history of any given post
34 | - **No CMS lock in** - We can easily port to any static site generator
35 | - **It's just simple** - No user accounts to manage, no CMS software to upgrade, no plugins to install.
36 |
37 | ---
38 |
39 | ## Markdown basics
40 |
41 | The basics of markdown can be found [here](https://guides.github.com/features/mastering-markdown/) & [here](https://daringfireball.net/projects/markdown/). Super easy!
42 |
43 | ### Image with alt & title
44 |
45 | ```
46 | 
47 | ```
48 |
49 | ## Advanced Formatting tips
50 |
51 | ### `left` alignment
52 |
53 |
54 |
55 | This is the code you need to align images to the left:
56 | ```
57 |
58 | ```
59 |
60 | ---
61 |
62 | ### `right` alignment
63 |
64 |
65 |
66 | This is the code you need to align images to the right:
67 | ```
68 |
69 | ```
70 |
71 | ---
72 |
73 | ### `center` alignment example
74 |
75 |
76 |
77 |
78 |
79 | ```
80 |
81 |
82 |
83 | ```
84 |
85 | ---
86 |
87 | ### Horizontal images no gap
88 |
89 | via [comment](https://gist.github.com/DavidWells/7d2e0e1bc78f4ac59a123ddf8b74932d?permalink_comment_id=4536101#gistcomment-4536101)
90 |
91 | ```html
92 |
93 |
94 |
95 |
96 | ```
97 |
98 |
99 |
100 |
101 |
102 |
103 | ---
104 |
105 | ### Horizontal images with gap
106 |
107 | With `hspace` property you can set horizontal (left and right) padding for an image
108 |
109 | ```html
110 |
111 |
112 |
113 |
114 | ```
115 |
116 |
117 |
118 |
119 |
120 |
121 | ---
122 |
123 | ### Vertical images with gap
124 |
125 | We also have a property "vspace", which does what it sounds like, add vertical spacing. But it doesn't seem to work on GitHub, unlike VSCode's buit in markdown viewer. So probably just add a `
` tag in between.
126 |
127 | ```html
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 | ```
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 | ---
146 |
147 | ### Adding video
148 |
149 | To add video you need to upload your video file and reference it inline
150 |
151 | ```
152 | https://user-images.githubusercontent.com/1702215/158075475-c23004ab-827a-45ad-bdba-aee29ac5b582.mp4
153 | ```
154 |
155 | Example:
156 |
157 | https://user-images.githubusercontent.com/1702215/158075475-c23004ab-827a-45ad-bdba-aee29ac5b582.mp4
158 |
159 | ### light/dark mode images
160 |
161 | Tip via this [tweet](https://twitter.com/stefanjudis/status/1465775940034781186). Swap out images based on theme settings
162 |
163 | ```
164 | 
165 | 
166 | ```
167 |
168 | ### Using [footnotes](https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/)
169 |
170 | Here is a simple footnote[^example]. With some additional text after it.
171 |
172 | [^example]: Example footnote
173 |
174 | ```
175 | Here is a simple footnote[^1]. With some additional text after it.
176 |
177 | [^1]: My reference.
178 | ````
179 |
180 | ### Strikethru text in markdown
181 |
182 | ~~text with line through it~~
183 |
184 | ```
185 | ~~text with line through it~~
186 | ```
187 |
188 | ### Tiny text in markdown
189 |
190 | Normal text here.
191 |
192 | Tiny text is here. Awwwww its so cuteeeeeeeeeee
193 |
194 | **How?**
195 |
196 | ```
197 | Add your tiny text
198 | ```
199 |
200 | ### Text box
201 |
202 | Add a box with contents to markdown
203 |
204 |
205 |
206 |
207 |
208 |
209 | This is text in the box. Much wow
210 |
211 |
212 |
213 |
214 |
215 |
216 | ```
217 |
218 |
219 |
220 |
221 |
222 | This is text in the box. Much wow
223 |
224 |
225 |
226 |
227 |
228 | ```
229 |
230 | ### `collapse` Sections
231 |
232 | Collapsing large blocks of text can make your markdown much easier to digest
233 |
234 |
235 | "Click to expand"
236 | this is hidden block
237 |
238 |
239 | ```
240 |
241 | "Click to expand"
242 | this is hidden
243 |
244 | ```
245 |
246 | Collapsing large blocks of Markdown text
247 |
248 |
249 | To make sure markdown is rendered correctly in the collapsed section...
250 |
251 | 1. Put an **empty line** after the `` block.
252 | 2. *Insert your markdown syntax*
253 | 3. Put an **empty line** before the `` tag
254 |
255 |
256 |
257 | ```
258 |
259 | To make sure markdown is rendered correctly in the collapsed section...
260 |
261 | 1. Put an **empty line** after the `` block.
262 | 2. *Insert your markdown syntax*
263 | 3. Put an **empty line** before the `` tag
264 |
265 |
266 | ```
267 |
268 | ---
269 |
270 | ## Mermaid Charts
271 |
272 | You can add fancy zoomable charts
273 |
274 | ```mermaid
275 | %%{ init: { "er" : { "layoutDirection" : "LR" } } }%%
276 | erDiagram
277 | User ||--o{ Vote : submits
278 | Vote o{--|| Link : on
279 | Link o{--|| Score : has
280 | ```
281 |
282 | Here's another cool example of a [sequence diagram](https://github.com/tom-barone/discontent/blob/431a6bd39216fd1f3018804a1dbe0967e22adfc5/docs/architecture.md#sequence-diagrams)
283 |
284 | ```mermaid
285 | sequenceDiagram
286 | actor Extension
287 | participant API
288 | participant Database
289 | Extension->>API: POST /vote {link, vote, user_id}`
290 | activate API
291 | API->>API: Validate parameters
292 | alt Invalid parameters
293 | API->>Extension: Error: Invalid parameters
294 | end
295 | API->>Database: Check user history & settings. GetBatchItems(___________)
296 | Note over API,Database: Voting disabled? GetItem(PK=settings, SK=settings)
297 | Note over API,Database: Too many votes? GetItem(PK=date, SK=user_id)
298 | Note over API,Database: User exists? User banned? GetItem(PK=user_id, SK=user_id)
299 | Note over API,Database: Already voted? GetItem(PK=link, SK=user_id)
300 | activate Database
301 | alt Database Error
302 | Database->>API: Database Error (connection / server...)
303 | API->>Extension: Server Error
304 | end
305 | Database->>API: Return UserHistory & Settings
306 | deactivate Database
307 | API->>API: Check user history & Settings
308 | alt Failed
309 | API->>Extension: 403 Forbidden: Too many votes / banned / voting disabled
310 | end
311 | activate Database
312 | API->>Database: Submit vote. BatchWriteItems(_________________)
313 | alt If user does not exist
314 | Note over API,Database: Put(PK=user_id, SK=user_id | not_banned,created_at)
315 | Note over API,Database:
316 | else First time user voting on link
317 | Note over API,Database: Put(PK=link, SK=user_id | vote)
318 | Note over API,Database: Update(PK=link, SK=link | count_of_votes++, sum_of_votes+=vote)
319 | Note over API,Database: -- Add history
320 | Note over API,Database: Update(PK=day, SK=link | count++, sum+=vote)
321 | Note over API,Database: Update(PK=day, SK=user | count++, sum+=vote)
322 | else If user already voted on link
323 | Note over API,Database: Put(PK=link, SK=user_id | vote)
324 | Note over API,Database: Update(PK=link, SK=link | sum_of_votes+=(-old_vote+new_vote))
325 | Note over API,Database: -- Undo old history
326 | Note over API,Database: Update(PK=old_day, SK=link | count--, sum-=old_vote)
327 | Note over API,Database: Update(PK=old_day, SK=user | count--, sum-=old_vote)
328 | Note over API,Database: -- Add history
329 | Note over API,Database: Update(PK=day, SK=link | count++, sum+=vote)
330 | Note over API,Database: Update(PK=day, SK=user | count++, sum+=vote)
331 | end
332 | activate Database
333 | alt Database Error
334 | Database->>API: Database Error (connection / server...)
335 | API->>Extension: Server Error
336 | end
337 | Database->>API: Return success
338 | API->>Extension: Return success
339 | deactivate Database
340 | deactivate API
341 | ```
342 |
343 | ---
344 |
345 | ### Call outs
346 |
347 | Add call outs in [markdown](https://github.com/community/community/discussions/16925)
348 |
349 | > [!NOTE]
350 | > Highlights information that users should take into account, even when skimming.
351 |
352 | > [!TIP]
353 | > Optional information to help a user be more successful.
354 |
355 | > [!IMPORTANT]
356 | > Crucial information necessary for users to succeed.
357 |
358 | > [!WARNING]
359 | > Critical content demanding immediate user attention due to potential risks.
360 |
361 | > [!CAUTION]
362 | > Negative potential consequences of an action.
363 |
364 | ```
365 | > [!NOTE]
366 | > Highlights information that users should take into account, even when skimming.
367 |
368 | > [!TIP]
369 | > Optional information to help a user be more successful.
370 |
371 | > [!IMPORTANT]
372 | > Crucial information necessary for users to succeed.
373 |
374 | > [!WARNING]
375 | > Critical content demanding immediate user attention due to potential risks.
376 |
377 | > [!CAUTION]
378 | > Negative potential consequences of an action.
379 | ```
380 |
381 | ### Emojis
382 |
383 | See a full list of [markdown emojis here](https://gist.github.com/rxaviers/7360908)
384 |
385 | ### `additional links`
386 |
387 | [Website](http://www.serverless.com) • [Email Updates](http://eepurl.com/b8dv4P) • [Gitter](https://gitter.im/serverless/serverless) • [Forum](http://forum.serverless.com) • [Meetups](https://github.com/serverless-meetups/main) • [Twitter](https://twitter.com/goserverless) • [Facebook](https://www.facebook.com/serverless) • [Contact Us](mailto:hello@serverless.com)
388 |
389 | ```
390 | [Website](http://www.serverless.com) • [Email Updates](http://eepurl.com/b8dv4P) • [Gitter](https://gitter.im/serverless/serverless) • [Forum](http://forum.serverless.com) • [Meetups](https://github.com/serverless-meetups/main) • [Twitter](https://twitter.com/goserverless) • [Facebook](https://www.facebook.com/serverless) • [Contact Us](mailto:hello@serverless.com)
391 | ```
392 |
393 | ---
394 |
395 | ### Badges
396 |
397 |