Skip to content

Commit

Permalink
Table of Contents block: convert line breaks to spaces in headings. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ZebulanStanphill committed May 22, 2022
1 parent 046ca65 commit 8dcb185
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/block-library/src/table-of-contents/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
/(<br *\/?>)+/g,
' '
)
),
level: headingAttributes.level,
link: canBeLinked
? `${ headingPageLink }#${ headingAttributes.anchor }`
Expand Down

0 comments on commit 8dcb185

Please sign in to comment.