Menu

How to format content of SimplyHTML properly?

2016-07-23
2016-07-24
  • Robertonisola

    Robertonisola - 2016-07-23

    Hi everybody,

    In an attempt to implement an advanced "search and highlight" feature in notes, I wrote a script to modify the content of "HTML Code View" directly.

    For example, the original content was:

    </p>
    <p>
      Freeplane is awesome.
    </p>
    <p>
    

    And here was my modification:

    </p>
    <p>
      <span style="background-color: #FFFF00">Freeplane is awesome</span>
    </p>
    <p>   
    

    At first, this modification worked as expected, the background color of "Freeplane is awesome" changed to the desired value.

    However, after a while, the color automatically changed back to normal, ie. no color at all.

    Pls help me to figure out what's going on.

    Thank you very much.

     

    Last edit: Robertonisola 2016-07-23
    • zipizap

      zipizap - 2016-07-23

      Paste or attach the script

       
  • Dimitry Polivaev

    <span> is not supported by freeplane rendering library which is so old that it does not understand it.
    Therefore we do not use this element at all and have to use much less powerful and deprecated formatting elements. The only thing which could help is to rewrite about 20-30 % of freeplane completely in order to use javafx instead of swing. I do not think we can afford it.

     
    • Volker Börchers

      Dimitry,

      that we can't use span and more css stuff is common knowledge shared by us developers. But the fact that this script works proves us wrong:

      node.text = '<html><body><p>normal <span style="background-color: #FFFF00">highlighted</span> normal</body></html>'
      

      You can even save and reload such maps - it first goes wrong when you open this in an SimplyHTML editor: This is the one that strips the tags. The simple editor doesn't do that.

      So I think that we could do much better at formatting if SimplyHTML would support it.

      Volker

       

      Last edit: Volker Börchers 2016-07-23
      • Dimitry Polivaev

        I think I have analyzed it some years ago and there was some problem either in writing html or in inserting html, I do not know it any more. I can look at it once more.

         
        • Volker Börchers

          Yes, that would be great. Perhaps you could let SimplyHTML keep constructs it doesn't understand verbatim.

           
          • Dimitry Polivaev

            The problem is described in http://www.thecodingforums.com/threads/inaccessible-features-htmlwriter.147651/ and http://stackoverflow.com/questions/20129731/font-tag-htmlwriter and I have not found any satisfactory solution yet. Probably we can just copy and adjust some code from HTMLWriter and fix it this way. Until now I have always taken it for not possible because it looks just crazy, but I could try it.

             
            • Dimitry Polivaev

              I tested it. It looks like method HTMLWriter.convertToHTML40 has never been completely developed. So the problem is how to write it and I have no idea.

               
  • Robertonisola

    Robertonisola - 2016-07-23

    Hi Dimitry and friends,

    After a thorough search, I found 2 other threads describing similar problem:

    https://sourceforge.net/p/freeplane/discussion/758437/thread/11da675c/

    https://sourceforge.net/p/freeplane/discussion/758437/thread/7a69aee5/

    In 2014, Volker Börchers said that "The old fashioned bgcolor attribute seems to work while the background-color style is stripped by the editor (after first recognizing it)."

    The problem with attribute bgcolor is that, it cannot be used to highlight a single word.

    So, to sum it up, is there any way to highlight part of text inside a note, programmatically?

     
    • Volker Börchers

      have you tried <font>?

       

      Last edit: Volker Börchers 2016-07-23
      • Robertonisola

        Robertonisola - 2016-07-24

        Hi Volker,

        As your suggestion, I have just tried tag <font>. However, it has also been stripped off automatically, like other tags.

        First I added this code to the note of a node:

        <font style="background-color: #FFFF00">Freeplane is awesome</font>
        

        Then I navigated to another node, and when I navigated back, it automatically became:

        Freeplane is awesome&#160;
        

        Which caused the highlight to disappear.

         

        Last edit: Robertonisola 2016-07-24