Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: Guillaume on November 17, 2023, 04:46:11 am

Title: Formatted notes export to HTML
Post by: Guillaume on November 17, 2023, 04:46:11 am
Hello,

I have a custom tool that queries the EA DB via the API to export the elements Notes to another tool.
To support the formatted notes, the expected format is HTML. It works ok i.e. the colors, bullets are properly rendered as the content includes tags like <li> <font> <b>...
The only issue is that carriage returns are not rendered since there are only line breaks but no <p> <br /> tags.
I made an attempt to replace line breaks with <br /> but it's not ideal when there are bullets <ul><li>...
Is there any better way to generate the HTML format? I tried to use the GetFieldFromFormat method but it didn't sort this issue.
Title: Re: Formatted notes export to HTML
Post by: Geert Bellekens on November 17, 2023, 05:15:02 am
If GetFieldFromFormat (or GetFormatFromField) doesn't do what you need, I guess you'll have to write the logic yourself.

Geert
Title: Re: Formatted notes export to HTML
Post by: johann on November 17, 2023, 08:36:19 pm
The format of the notes field is not HTML. It is plain text that supports a very limited set of HTML tags.
Your problem is that white space is significant in plain text, but not in HTML.

This can be fixed in a Browser by applying proper CSS styles for white space, for example:

Code: [Select]
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Sparx Notes</title>
    <style>
      .note { white-space: pre-wrap; }
      .note ul, .note ol { white-space:normal; margin:0; }
      .note li { white-space:pre-wrap; }
    </style>
  </head>
  <body>
    <div class="note" xml:space="preserve"><b>Test Step 1</b>
Results of all tests: PASSED

<b>Test Step 2</b>
<ul>
<li>Result of all tests: PASSED</li>
<li>MC/DC (if available) or Branch Coverage = 100%
If 100% coverage could not be reached for individual units, an explanation has to be provided.</li>
</ul></div>
  </body>
</html>
Title: Re: Formatted notes export to HTML
Post by: Guillaume on November 17, 2023, 08:50:44 pm
I ended up updating the notes content by processing each line.
If the line doesn't start with <ul or <li (having removed starting tabs and spaces), a <BR> tag is added.

So far I identified the following set of HTML tags used in EA notes: <a href...>, <ol>, <ul>, <li>, <font..>, <b>, <i>, <u>, <sub>, <sup>
Title: Re: Formatted notes export to HTML
Post by: qwerty on November 18, 2023, 12:07:22 am
That should be it. EA's internal "html" is rather crippled.