@@ -1525,6 +1525,53 @@ describe('Post', () => {
15251525 data . content . should . contains ( '22222' ) ;
15261526 } ) ;
15271527
1528+ it ( 'render() - tags with swig character' , async ( ) => {
1529+ const tagSpy = spy ( ) ;
1530+ hexo . extend . tag . register ( 'testTag' , ( args , content ) => {
1531+ tagSpy ( args , content ) ;
1532+ return '' ;
1533+ } , {
1534+ ends : true
1535+ } ) ;
1536+ let content = '{% testTag 111 222 %}\n3333\n{% endtestTag %}' ;
1537+ await post . render ( '' , {
1538+ content,
1539+ engine : 'markdown'
1540+ } ) ;
1541+ tagSpy . calledOnce . should . be . true ;
1542+ tagSpy . firstCall . args [ 0 ] . should . eql ( [ '111' , '222' ] ) ;
1543+ tagSpy . firstCall . args [ 1 ] . should . eql ( '3333' ) ;
1544+
1545+ content = '{% testTag 111% % 222 %}\n333\n{% endtestTag %}' ;
1546+ await post . render ( '' , {
1547+ content,
1548+ engine : 'markdown'
1549+ } ) ;
1550+ tagSpy . calledTwice . should . be . true ;
1551+ tagSpy . secondCall . args [ 0 ] . should . eql ( [ '111%' , '%' , '222' ] ) ;
1552+ tagSpy . secondCall . args [ 1 ] . should . eql ( '333' ) ;
1553+
1554+ content = '{% testTag 111 } 222} %}\n333\n{% endtestTag %}' ;
1555+ await post . render ( '' , {
1556+ content,
1557+ engine : 'markdown'
1558+ } ) ;
1559+ tagSpy . calledThrice . should . be . true ;
1560+ tagSpy . thirdCall . args [ 0 ] . should . eql ( [ '111' , '}' , '222}' ] ) ;
1561+ tagSpy . thirdCall . args [ 1 ] . should . eql ( '333' ) ;
1562+
1563+ content = '{% testTag 111 222 %}\n333% % } %}\n{% endtestTag %}' ;
1564+ await post . render ( '' , {
1565+ content,
1566+ engine : 'markdown'
1567+ } ) ;
1568+ tagSpy . callCount . should . eql ( 4 ) ;
1569+ tagSpy . getCall ( 3 ) . args [ 0 ] . should . eql ( [ '111' , '222' ] ) ;
1570+ tagSpy . getCall ( 3 ) . args [ 1 ] . should . eql ( '333% % } %}' ) ;
1571+
1572+ hexo . extend . tag . unregister ( 'testTag' ) ;
1573+ } ) ;
1574+
15281575 it ( 'render() - incomplete tags throw error' , async ( ) => {
15291576 const content = 'nunjucks should throw {# } error' ;
15301577
0 commit comments