@@ -24,7 +24,6 @@ export const prevChild = (data: Literal[] = [], index: number): Comment | undefi
24
24
25
25
export const nextChild = ( data : RootContent [ ] | ElementContent [ ] = [ ] , index : number , tagName ?: string , codeBlockParames ?: boolean ) : ElementContent | undefined => {
26
26
let i = index ;
27
-
28
27
while ( i < data . length ) {
29
28
i ++ ;
30
29
if ( tagName ) {
@@ -36,13 +35,17 @@ export const nextChild = (data: RootContent[] | ElementContent[] = [], index: nu
36
35
const element = data [ i ] as ElementContent & Literal ;
37
36
if ( ! element || element . type === 'element' ) return ;
38
37
if ( element . type === 'text' && element . value . replace ( / ( \n | \s ) / g, '' ) !== '' ) return ;
39
- if ( element ?. type === 'comment' ) {
40
- if ( ! / ^ r e h y p e : / . test ( element . value as string ) ) return ;
38
+ if ( / ^ ( c o m m e n t | r a w ) $ / ig. test ( element ?. type ) ) {
39
+ if ( ! / ^ r e h y p e : / . test ( element . value ?. replace ( / ^ ( \s + ) ? < ! - - ( .* ?) - - > / , '$2' ) || '' ) ) {
40
+ return
41
+ } ;
41
42
if ( codeBlockParames ) {
42
43
const nextNode = nextChild ( data , i , 'pre' , codeBlockParames )
43
44
if ( nextNode ) return ;
45
+ element . value = element . value ?. replace ( / ^ ( \n | \s ) + / , '' )
44
46
return element ;
45
47
} else {
48
+ element . value = element . value ?. replace ( / ^ ( \n | \s ) + / , '' )
46
49
return element ;
47
50
}
48
51
}
@@ -58,7 +61,7 @@ export const nextChild = (data: RootContent[] | ElementContent[] = [], index: nu
58
61
* @returns 返回 当前参数数据 Object,`{}`
59
62
*/
60
63
export const getCommentObject = ( { value = '' } : Comment ) : Properties => {
61
- const param = getURLParameters ( value . replace ( / ^ r e h y p e : / , '' ) ) ;
64
+ const param = getURLParameters ( value . replace ( / ^ < ! - - ( . * ? ) - - > / , '$1' ) . replace ( / ^ r e h y p e : / , '' ) ) ;
62
65
Object . keys ( param ) . forEach ( ( keyName : string ) => {
63
66
if ( param [ keyName ] === 'true' ) {
64
67
param [ keyName ] = true ;
0 commit comments