Author Topic: Formatted notes export to HTML  (Read 2760 times)

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1370
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Formatted notes export to HTML
« 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.
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13381
  • Karma: +563/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Formatted notes export to HTML
« Reply #1 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

johann

  • EA User
  • **
  • Posts: 27
  • Karma: +2/-0
    • View Profile
Re: Formatted notes export to HTML
« Reply #2 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>

Guillaume

  • EA Practitioner
  • ***
  • Posts: 1370
  • Karma: +42/-2
    • View Profile
    • www.umlchannel.com
Re: Formatted notes export to HTML
« Reply #3 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>
Guillaume

Blog: www.umlchannel.com | Free utilities addin: www.eautils.com


qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Formatted notes export to HTML
« Reply #4 on: November 18, 2023, 12:07:22 am »
That should be it. EA's internal "html" is rather crippled.