File tree Expand file tree Collapse file tree 1 file changed +27
-13
lines changed
Expand file tree Collapse file tree 1 file changed +27
-13
lines changed Original file line number Diff line number Diff line change @@ -85,24 +85,38 @@ export class Compiler {
8585 }
8686
8787 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+ }
9097
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 ( )
94106
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 ]
97114 } else {
98- html = compile . parser ( text )
115+ this . cacheTOC [ curFileName ] = [ ... this . toc ]
99116 }
100117
101- html = config . noEmoji ? html : emojify ( html )
102- slugify . clear ( )
103-
104- return html
105- } )
118+ return result
119+ }
106120 }
107121
108122 compileEmbed ( href , title ) {
You can’t perform that action at this time.
0 commit comments