File tree Expand file tree Collapse file tree 4 files changed +80
-2
lines changed Expand file tree Collapse file tree 4 files changed +80
-2
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ easier to discuss...
8
8
Here's the TLDR; in terms of actual blocking TODOs if we wanted to stick with
9
9
this branch:
10
10
11
- - [ ] Finish porting the markdown process to ` remark ` (may require new plugins)
11
+ - [ ] Finish porting the markdown process to ` remark ` (may require new plugins) (Fernando)
12
12
- [ ] Rethink external population process
13
13
- [x] Extract anchors into ` _content.json ` via ` DirectoryTreePlugin ` (Fernando)
14
14
- [ ] Finish re-incorporating mobile sidebar
Original file line number Diff line number Diff line change 78
78
border-left : 4px solid #dddddd ;
79
79
padding :0.75em 1em ;
80
80
color :getColor (dove-grey );
81
+ font-style : italic ;
81
82
82
83
> :first-child { margin-top : 0 ; }
83
84
> :last-child { margin-bottom : 0 ; }
Original file line number Diff line number Diff line change
1
+ // var unified = require('unified');
2
+ // var parse = require('remark-parse');
3
+ // var html = require('remark-html');
4
+ var visit = require ( 'unist-util-visit' ) ;
5
+
6
+ // const md = `T> This is a tip.
7
+
8
+ // The [configuration](/configuration) properties should be ordered alphabetically as well:
9
+
10
+ // W> This is a warning.
11
+
12
+ // ?> This is a todo.`;
13
+
14
+ // const header = `## Header`;
15
+
16
+ // const md = "T> The `output` property has [many more configurable features](/configuration/output) and if you like to know more about the concepts behind the `output` property, you can [read more in the concepts section](/concepts/output)."
17
+
18
+ const classMap = {
19
+ 'T>' : 'tip' ,
20
+ 'W>' : 'warning' ,
21
+ '?>' : 'todo'
22
+ } ;
23
+
24
+ // unified()
25
+ // .use(parse)
26
+ // .use(tip)
27
+ // .use(html)
28
+ // .process(md, function(err, file) {
29
+ // console.log({ err })
30
+ // console.log(file);
31
+ // });
32
+
33
+ module . exports = tip ;
34
+
35
+ function tip ( options ) {
36
+ return transformer ;
37
+ }
38
+
39
+ function transformer ( tree , file ) {
40
+ visit ( tree , 'paragraph' , visitor ) ;
41
+
42
+ function visitor ( node ) {
43
+ const { children } = node ;
44
+ const textNode = children [ 0 ] . value ;
45
+
46
+ if ( ! textNode ) return ;
47
+
48
+ if (
49
+ textNode . startsWith ( 'T>' ) ||
50
+ textNode . startsWith ( 'W>' ) ||
51
+ textNode . startsWith ( '?>' )
52
+ ) {
53
+ let className = classMap [ textNode . substr ( 0 , 2 ) ] ;
54
+
55
+ node . type = 'blockquote' ;
56
+ node . data = {
57
+ hName : 'blockquote' ,
58
+ hProperties : {
59
+ className
60
+ }
61
+ } ;
62
+ node . children = [
63
+ {
64
+ type : 'paragraph' ,
65
+ children : [
66
+ {
67
+ ...children [ 0 ] ,
68
+ value : children [ 0 ] . value . slice ( 3 )
69
+ } ,
70
+ ...children . slice ( 1 )
71
+ ]
72
+ }
73
+ ] ;
74
+ }
75
+ }
76
+ }
Original file line number Diff line number Diff line change @@ -37,14 +37,15 @@ module.exports = (env = {}) => ({
37
37
options : {
38
38
plugins : [
39
39
// TODO: Add necessary remark plugins
40
+ require ( './tip' ) ,
40
41
require ( 'remark-slug' ) ,
41
42
[
42
43
require ( 'remark-autolink-headings' ) ,
43
44
{
44
45
behaviour : 'append'
45
46
}
46
47
] ,
47
- require ( 'remark-html' )
48
+ require ( 'remark-html' ) ,
48
49
require ( 'remark-mermaid' )
49
50
]
50
51
}
You can’t perform that action at this time.
0 commit comments