Striphtml is clearing line breaks

Originally asked by Francis Martens (Exalate) on 25 March 2021 (original question)


I see the code to strip the HTML from the field. However, it also strips our the line breaks. Is there a happy median where it does not maintain the HTML code but still keeps the line breaks?


Answer by Francis Martens (Exalate) on 25 March 2021

This is to be expected.

  • html will represent a line break with a <br> tag
  • striphtml will remove all tags including <br>

The transformation of the formatting from one system to another requires some understanding. Depending on the platform different types of renderers are used

  • Zendesk - HTML
  • ServiceNow - text and HTML
  • Jira Cloud - Markdown
  • Jira On Premise - text and wiki
  • Github - text and Markdown
  • AzureDevOps - HTML

Whenever syncing, be sure that the conversion is done correctly.
For instance - when syncing from AzureDevOps into a html field on ServiceNow - no transformation is required, as both platforms ‘understand’ html

To give it a try

  • Setup a connection between ADO to SNOW
  • Configure an HTML field on SNOW in incident
  • Add following code snippet in the incoming sync on the service now side
    entity.description = replica.description
    entity.u_html_description = replica.description
  • Exalate a workitem to an incident. Make sure that the description has some formatting

The workitem

The incident

As you can see the description is garbled - because it cannot render the html, but the html_description is.