This repository was archived by the owner on Jun 4, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 3
3
*/
4
4
hexo . extend . tag . register ( 'colorquote' , function ( args , content ) {
5
5
var type = args [ 0 ] ;
6
- return '<blockquote class="colorquote ' + type + '">' + content + '</blockquote>' ;
7
- } , { ends : true } ) ;
6
+ return '<blockquote class="colorquote ' + type + '">' + hexo . render . renderSync ( { text : content , engine : 'markdown' } ) + '</blockquote>' ;
7
+ } , { ends : true } ) ;
8
+
9
+ const rEscapeContent = / < e s c a p e (?: [ ^ > ] * ) > ( [ \s \S ] * ?) < \/ e s c a p e > / g;
10
+ const placeholder = '\uFFFD' ;
11
+ const rPlaceholder = / (?: < | & l t ; ) \! - - \uFFFD ( \d + ) - - (?: > | & g t ; ) / g;
12
+ const cache = [ ] ;
13
+ function escapeContent ( str ) {
14
+ return '<!--' + placeholder + ( cache . push ( str ) - 1 ) + '-->' ;
15
+ }
16
+ hexo . extend . filter . register ( 'before_post_render' , function ( data ) {
17
+ data . content = data . content . replace ( rEscapeContent , function ( match , content ) {
18
+ return escapeContent ( content ) ;
19
+ } ) ;
20
+ return data ;
21
+ } ) ;
22
+
23
+ hexo . extend . filter . register ( 'after_post_render' , function ( data ) {
24
+ data . content = data . content . replace ( rPlaceholder , function ( ) {
25
+ return cache [ arguments [ 1 ] ] ;
26
+ } ) ;
27
+ return data ;
28
+ } ) ;
You can’t perform that action at this time.
0 commit comments