From 96dad1744ba636ef645de79201df12deaedf2cdd Mon Sep 17 00:00:00 2001 From: Zebulan Stanphill Date: Fri, 20 May 2022 10:30:23 -0500 Subject: [PATCH] Table of Contents block: convert line breaks to spaces in headings. --- packages/block-library/src/table-of-contents/edit.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/block-library/src/table-of-contents/edit.js b/packages/block-library/src/table-of-contents/edit.js index d20a5981021ce..67936ea269ce4 100644 --- a/packages/block-library/src/table-of-contents/edit.js +++ b/packages/block-library/src/table-of-contents/edit.js @@ -187,7 +187,13 @@ export default function TableOfContentsEdit( { headingAttributes.anchor !== ''; _latestHeadings.push( { - content: stripHTML( headingAttributes.content ), + // Convert line breaks to spaces, and get rid of HTML tags in the headings. + content: stripHTML( + headingAttributes.content.replace( + /(
)+/g, + ' ' + ) + ), level: headingAttributes.level, link: canBeLinked ? `${ headingPageLink }#${ headingAttributes.anchor }`