14 Replies Latest reply on May 9, 2016 2:46 AM by beverly

    Text to HTML

    Steven_FL

      Any one knows how to convert text, formatted text to HTML not to CSS.

      Or CSS to HTML.

      Outlook supports only HTML and not CSS.

        • 1. Re: Text to HTML

          Can you describe your use-case a bit more?

           

          For example where is the text coming from? A FileMaker Field?

           

          When you say "Formatted Text", what exactly do you mean? Rich text with images, fonts, etc.?

           

          Do you need the functionality native to FileMaker or could it be an external program that's accessing FM to give you custom functionality?

           

          ---------------------------

           

          Some ideas...

           

          Using Java, again, depending on what your needs are, I might try this like this:

           

          http://stackoverflow.com/questions/5134959/convert-plain-text-to-html-text-in-java

           

          ----

           

          You could also try to convert the text -> XML and then apply an XSLT to it.

           

          beverly has done lots of XML/XSLT in FM and could offer ideas. I've done tons of XML programming, but I would never choose to do that in FM.

           

          ----

           

          Have you checked some of the plug-ins like MBS, or others?

           

          ----

           

          Just some ideas.

           

          HOPE THIS HELPS.

           

          - m

          • 2. Re: Text to HTML
            beverly

            the GetAsCSS() function is really:

            GetAsHTML_formatting. It uses the SPAN tag and all formatting is in the attribute STYLE. There is no external or referenced CSS.

            It's very old HTML, but probably valid in the browsers and email clients.

            the example:

            <SPAN STYLE = “font-family: 'Helvetica';font-size: 12px;color:#FF0000;font-weight: bold;text-align: left;”>Frank</SPAN>

            this may work as is (or NOT!)

            It needs to be tested for the email clients used by those who may receive your messages.

            beverly

            • 3. Re: Text to HTML
              Steven_FL

              Dear Morkus,

              the text would come from a FM text field that user can modify the fonts, size and color etc.

              and then that modification would need to have as HTML.

              I dont want to have any plugins into FM.

              But if it can be done java and then the webviewer copied that would be working.

              • 4. Re: Text to HTML
                Steven_FL

                Dear Beverly,

                 

                Nope it is not doing HTLM it is doing inline CSS.

                 

                Here a example

                red bold house

                with Text to CSS looks like this:

                <span style=\"color: #FF2712;\" >red</span><span style=\"\" > </span><span style=\"font-family: 'Tahoma';font-weight: bold;\" >bold</span><span style=\"\" > house</span>

                And that is inline CSS

                HTML would be

                  <font color="red">red</font>  <strong>blod</strong>house.

                This text Outlook can accept with VBA. You have an idea how to get the formated text to HTML?

                • 5. Re: Text to HTML

                  So, you're saying you want to capture in the HTML the font, font color, that the user has in a text field?

                   

                  Since FM is not object oriented, I don't know how you would do something like:

                   

                  textField.getSelectedColor();

                   

                  or

                   

                  textField.getCurrentFont()

                   

                  Unless I'm missing something, FM can't do this other than its built-in functions, plug-ins, or something you craft separately (user interface fields, for example) that uses these.

                   

                  ----

                   

                  But just creating HTML shouldn't be that difficult. You could use Beverly's idea or just write your own HTML tags.

                   

                  HOPE THIS HELPS.

                   

                  - m

                  • 6. Re: Text to HTML
                    beverly

                    HTML FONT tag (not supported in HTML5). sorry not a current answer

                    You could 'substitute()' one supposes, what you get with GetAsCSS().

                    beverly

                    • 7. Re: Text to HTML
                      monkeybreadsoftware

                      We could build something.

                       

                      Did you try Text.TextToHTML in MBS Plugin?

                      • 8. Re: Text to HTML

                        That looks like a great solution to me, but the OP doesn't want to use plug-ins, or so he wrote above.

                         

                        - m

                        • 9. Re: Text to HTML

                          Beverly's right.

                           

                          This is a common situation, not limited to FMP in any way, where the environment you're working in can get you part of the way where you want to go, but you need to augment that built-in result with programming, plug-ins, or external stuff (like JDBC, etc.)

                           

                          - m

                          • 10. Re: Text to HTML
                            user19752

                            I think you missed to make example, but there need some AI for getting #FF2712 as "red".http://www.color-hex.com/color/ff2712

                            #ff2712 Color Hex

                            • 11. Re: Text to HTML
                              user19752

                              Built-in function GetAsCSS (or SVG) can get only modified font/color/size, not default ones on layout. So you need to hard code in the process.

                               

                              LayoutObjectAttributes() need more options...

                              • 12. Re: Text to HTML
                                Steven_FL

                                Dear All,

                                 

                                thanks for the many inputs. I think that I will try Beverley's solution, sounds like a good way to go.

                                thanks again to all for the contribution.

                                Steven

                                • 13. Re: Text to HTML
                                  beverly

                                  Hopefully, the text is pasted (from Word, perhaps?) or manually 'styled'.

                                   

                                  But u is correct. If your field is "styled" on the layout, it will not have formatting pushed.

                                  <span style="">content</span>

                                  However, line breaks (< b r >) and other entities will be converted.

                                  & -> &amp;

                                  Also by the definition for the functions:

                                  The GetAsCSS function does not return formats that are set in the Conditional Formatting dialog box.

                                   

                                  The GetAsSVG function does not return formats that are set in the Conditional Formatting dialog box.

                                   

                                  BTW, GetAsSVG() is another possibility!

                                  SVG supports more text formats than HTML, so SVG will represent what you have typed more accurately.

                                  You'd still need to play with it to match old HMTL (pre v5)!

                                  beverly

                                  • 14. Re: Text to HTML
                                    beverly

                                    If one is using old HTML FONT tags, the COLOR attribute can use any of these formats:

                                    • colorName - red, for example

                                    • HEX - (#rrggbb), #ff0000, #FF0000

                                    • rgb(r,g,b) - (same as FileMaker RGB function)

                                    Probably no conversion is needed, however, this is great info!