diff --git a/lib/plugins/helper/toc.js b/lib/plugins/helper/toc.js index 5f3f7e5f90..ef7d058c7a 100644 --- a/lib/plugins/helper/toc.js +++ b/lib/plugins/helper/toc.js @@ -25,7 +25,7 @@ function tocHelper(str, options) { headings.each(function() { var level = +this.name[1]; var id = $(this).attr('id'); - var text = $(this).text(); + var text = $(this).html(); lastNumber[level - 1]++; diff --git a/test/scripts/helpers/toc.js b/test/scripts/helpers/toc.js index 8b3528ef16..5244d9a878 100644 --- a/test/scripts/helpers/toc.js +++ b/test/scripts/helpers/toc.js @@ -16,7 +16,8 @@ describe('toc', () => { '

Title 1.3

', '

Title 1.3.1

', '

Title 2

', - '

Title 2.1

' + '

Title 2.1

', + '

Title should escape &, <, ', and "

', ].join(''); var genResult = options => { @@ -102,6 +103,12 @@ describe('toc', () => { 'Title 2', '', ifTrue(maxDepth >= 2, resultTitle_2_1, ''), + '', + '
  • ', + '', + ifTrue(listNumber, '3. ', ''), + 'Title should escape &, <, ', and "', + '', '
  • ' ].join('');