question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with <br> in v3

See original GitHub issue

When I was using v2 with the autoTableHtmlToJson(), I am able to get line break with the <br> tag. However after using v3 with the html option, I am not able to get it anymore.

For example, a text like this: Morbi lectus felis, <br> accumsan id hendrerit nec, <br> scelerisque ut tellus.

Will become like this: Morbi lectus felis, accumsan id hendrerit nec, scelerisque ut tellus.

My options are like this:

doc.autoTable({
			html:tbl,
			theme:'grid',
			rowPageBreak: 'avoid',
			styles: { overflow: 'linebreak',lineWidth : 1,lineColor : 200 }, //??
			columnStyles: {0: {cellWidth: 250},1: {cellWidth: 265}},
			});

May I ask is this my own problem or v3 does not allow line break with
anymore? Thanks a lot!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
webwakkocommented, May 10, 2019

maybe this can help. Add your break like this in your html.

Morbi lectus felis, <br />\n accumsan id hendrerit nec, <br />\n

adding the simple \n part solved the issue for me 😉

0reactions
arunlalkpcommented, Dec 30, 2020

“The Library always looking for \n to render the next line / Line break in the table cell.”

If you working with angular, Then angular always render with a random attribute within the tag ( eg:<br _ngcontent-lfs-c183> ) so the library can not identify and split with <br> and add \n at the end of each split value

So parse td cell content with InnerHTML Directive

<td [innerHTML]="parseNextLine(textToRender)"></td>

and create a function that converts \n to <br>

parseNextLine(text) { return text.replace(/(\\r\\n)|([\r\n])/gmi, '<br>');}

please note: <br/> is not accepted by the library at all use only <br>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it sometimes bad to use <BR />? - Stack Overflow
The main reason for not using <br> is that it's not semantic. If you want two items in different visual blocks, you probably...
Read more >
Problem with <br> Tag in Chrome/Windows - Tumult Forums
The problem is you have a character along with the text within the quotes. The character only shows up on PC but is...
Read more >
<br>: The Line Break element - HTML - MDN Web Docs - Mozilla
The HTML element produces a line break in text (carriage-return). It is useful for writing a poem or an address, where the division...
Read more >
The problem with the line break (BR) tag - Davin's blog
Common reasons to use line breaks · Trying to avoid an orphan · Inserting a line break before a 2-word proper noun, like...
Read more >
HTML br tag - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found