-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbasic-usage.js
More file actions
79 lines (58 loc) · 1.67 KB
/
basic-usage.js
File metadata and controls
79 lines (58 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* basic-usage.js
*
* Demonstrates how to use markdown-regex patterns to extract
* various elements from a markdown string.
*
* Run with: node examples/basic-usage.js
*/
import {
REGEXP_HEADER,
REGEXP_IMAGE,
REGEXP_LINK,
REGEXP_STRONG,
REGEXP_EM,
REGEXP_CODE,
REGEXP_DEL,
REGEXP_BLOCKQUOTE,
REGEXP_HR,
REGEXP_UL_LIST,
REGEXP_OL_LIST,
} from 'markdown-regex';
const markdown = `
# My Document Title
## Introduction
This is a [link to example](https://example.com) and an .
Here is some **bold text** and _italic text_ and ~~strikethrough~~.
Here is some \`inline code\`.
> This is a blockquote.
-----
* First unordered item
* Second unordered item
* Third unordered item
1. First ordered item
2. Second ordered item
3. Third ordered item
`;
console.log('=== Headers ===');
console.log(markdown.match(REGEXP_HEADER));
console.log('\n=== Links ===');
console.log(markdown.match(REGEXP_LINK));
console.log('\n=== Images ===');
console.log(markdown.match(REGEXP_IMAGE));
console.log('\n=== Bold / Strong ===');
console.log(markdown.match(REGEXP_STRONG));
console.log('\n=== Italic / Emphasis ===');
console.log(markdown.match(REGEXP_EM));
console.log('\n=== Inline Code ===');
console.log(markdown.match(REGEXP_CODE));
console.log('\n=== Strikethrough ===');
console.log(markdown.match(REGEXP_DEL));
console.log('\n=== Blockquotes ===');
console.log(markdown.match(REGEXP_BLOCKQUOTE));
console.log('\n=== Horizontal Rules ===');
console.log(markdown.match(REGEXP_HR));
console.log('\n=== Unordered Lists ===');
console.log(markdown.match(REGEXP_UL_LIST));
console.log('\n=== Ordered Lists ===');
console.log(markdown.match(REGEXP_OL_LIST));