Skip to content

Commit

Permalink
exclude pre and br tag from the html elements
Browse files Browse the repository at this point in the history
  • Loading branch information
marecar3 committed Nov 28, 2019
1 parent 80d275f commit dc7ca04
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/rich-text/src/component/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ export class RichText extends Component {

willTrimSpaces( html ) {
// regex for detecting spaces around block element html tags
const blockHtmlElements = '(div|br|blockquote|ul|ol|li|p|pre|h1|h2|h3|h4|h5|h6|iframe|hr)';
// aztec won't trimm spaces in a case of <pre> block, so we are excluding it
const blockHtmlElements = '(div|blockquote|ul|ol|li|p|h1|h2|h3|h4|h5|h6|iframe|hr)';
const leadingOrTrailingSpaces = new RegExp( `(\\s+)<\/?${ blockHtmlElements }>|<\/?${ blockHtmlElements }>(\\s+)`, 'g' );
const matches = html.match( leadingOrTrailingSpaces );
if ( matches && matches.length > 0 ) {
Expand Down

0 comments on commit dc7ca04

Please sign in to comment.