Commit 9e86017 1 parent 47a8d5f commit 9e86017 Copy full SHA for 9e86017
File tree 1 file changed +27
-13
lines changed
1 file changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -85,24 +85,38 @@ export class Compiler {
85
85
}
86
86
87
87
this . _marked = compile
88
- this . compile = cached ( text => {
89
- let html = ''
88
+ this . compile = text => {
89
+ let isCached = true
90
+ const result = cached ( _ => {
91
+ isCached = false
92
+ let html = ''
93
+
94
+ if ( ! text ) {
95
+ return text
96
+ }
90
97
91
- if ( ! text ) {
92
- return text
93
- }
98
+ if ( isPrimitive ( text ) ) {
99
+ html = compile ( text )
100
+ } else {
101
+ html = compile . parser ( text )
102
+ }
103
+
104
+ html = config . noEmoji ? html : emojify ( html )
105
+ slugify . clear ( )
94
106
95
- if ( isPrimitive ( text ) ) {
96
- html = compile ( text )
107
+ return html
108
+ } ) ( text )
109
+
110
+ const curFileName = this . router . parse ( ) . file
111
+
112
+ if ( isCached ) {
113
+ this . toc = this . cacheTOC [ curFileName ]
97
114
} else {
98
- html = compile . parser ( text )
115
+ this . cacheTOC [ curFileName ] = [ ... this . toc ]
99
116
}
100
117
101
- html = config . noEmoji ? html : emojify ( html )
102
- slugify . clear ( )
103
-
104
- return html
105
- } )
118
+ return result
119
+ }
106
120
}
107
121
108
122
compileEmbed ( href , title ) {
You can’t perform that action at this time.
0 commit comments