mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-25 02:09:50 +02:00
Extracted out the commonly used line break regex
This commit extract the commonly used /br\s*\/?>/gi regex to common.js, in order to keep the code more DRY.
This commit is contained in:
@@ -282,7 +282,7 @@ const drawForkJoinState = (g, stateDef) => {
|
||||
|
||||
export const drawText = function(elem, textData) {
|
||||
// Remove and ignore br:s
|
||||
const nText = textData.text.replace(/<br\s*\/?>/gi, ' ');
|
||||
const nText = textData.text.replace(common.lineBreakRegex, ' ');
|
||||
|
||||
const textElem = elem.append('text');
|
||||
textElem.attr('x', textData.x);
|
||||
@@ -310,7 +310,7 @@ const _drawLongText = (_text, x, y, g) => {
|
||||
|
||||
let text = _text.replace(/\r\n/g, '<br/>');
|
||||
text = text.replace(/\n/g, '<br/>');
|
||||
const lines = text.split(/<br\s*\/?>/gi);
|
||||
const lines = text.split(common.lineBreakRegex);
|
||||
|
||||
let tHeight = 1.25 * getConfig().state.noteMargin;
|
||||
for (const line of lines) {
|
||||
|
Reference in New Issue
Block a user