NetTalk Central

Author Topic: xHTML to Text  (Read 7547 times)

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
xHTML to Text
« on: February 08, 2016, 10:03:29 AM »
Hi,

NT9.05 Apps
Cl 10

I need to convert an xHTML field to Text to include in an email body.
Any ideas?

Brian
Brian

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: xHTML to Text
« Reply #1 on: February 08, 2016, 11:05:59 PM »
string theory?

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: xHTML to Text
« Reply #2 on: February 09, 2016, 07:55:43 AM »
Looked at String Theory but not sure I understand it if it is there?
Brian

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: xHTML to Text
« Reply #3 on: February 09, 2016, 07:56:37 AM »
For now I moved all fields back to plain text so I don't have this issue.

Thanks.
Brian

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: xHTML to Text
« Reply #4 on: February 09, 2016, 02:19:09 PM »
I was thinking you could use ST to remove all tags and convert some to cr\lf etc to automatically translate from xhtml to plain text.

broche

  • Sr. Member
  • ****
  • Posts: 336
    • View Profile
    • Email
Re: xHTML to Text
« Reply #5 on: February 10, 2016, 12:07:04 AM »
Thanks, yes I looked at doing that.  My limitation is knowing all the tags I suppose.
I will tackle this in my test environment as I like the xHTML look for the text fields for my customers.
Brian

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: xHTML to Text
« Reply #6 on: February 10, 2016, 02:05:17 PM »
check out remove in ST it might do the trick.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11297
    • View Profile
Re: xHTML to Text
« Reply #7 on: February 14, 2016, 11:00:38 PM »
see RemoveAttributes
http://www.capesoft.com/docs/StringTheory/StringTheory.htm#stRemoveAttributes

That cleans it up a bit. Then Replace to replace some tags with text - for example replacing <br> or <br/> or <p> with CR/LF (ie '<13,10>')

Then other tags need replacing as well, some requiring some thought, especially <ol> and <ul> (ordered and unordered lists), tables and so on.

Cheers
Bruce