1

Does anyone have any thoughts on how best to handle the import of large chunks of body copy that are already formatted with basic html (p tags and br's mostly)?

Datagrab can obviously do the heavy lifting of the actual import, but I'm then left with textareas full of compacted, marked up copy that's hard to read.

Should I look to replace all the p tags with newline/carriage returns prior to import and then import them to a field with 'xhtml' formatting (or an RTE field), or is there some other way?

2 Answers 2

3

It really all depends on what field you're ultimately going to import into. If you're importing into an XML-formatted textarea or a Rich Text Editor field, then you'll need to totally remove both the <p> and <br> tags, because EE adds those tags dynamically when inserting the content into the template, and, as you said, replace them with carriage returns so EE knows where to place the tags. That can be accomplished with a simple Find/Replace query.

If you're importing into a 3rd-party WYSIWYG field like Wygwam or Wyvern, you don't need to make any changes at all. Leave all the tags as-is and they will be parsed the same.

8
  • 1
    You don't need to remove HTML for the native Auto-XHTML formatted textarea field. The OP's issue is not that after importing the output is incorrect, it's that they are hard to read in the form when editing. May 22, 2014 at 16:40
  • Thanks Kristen, I hadn't realised that the 3rd party wysiwygs work differently from the native RTE, so will hopefully give that a shot instead of messing about with find and replace, especially since many of the fields require right-to-left support and use all kinds of foreign non-latin characters. May 22, 2014 at 20:07
  • @DerekJones So you don't have to remove the tags for an XML textarea field, but you do have to remove them for an RTE field?
    – kmgdev
    May 22, 2014 at 20:17
  • I can confirm things go a bit weird if you use a native RTE field with a field full of p tags. The native XHTML (not XML) format would indeed be ok, as it recognises and doesn't touch the pre-existing markup, but that's basically just the same as setting the formatting to 'None'... As Derek says, it's not the output that's my problem, it's the unreadable format in the CP. May 22, 2014 at 20:36
  • @JamesSmith How was the data displayed in the old CMS? On a WYSIWYG? Or did it de-compress the data before displaying it in the back-end?
    – kmgdev
    May 22, 2014 at 22:10
1

One option you could try is to convert the HTML to Markdown format and import that into a MarkItUp or Markdown formatted text field.

Brett Terpstra's online Markdownifier tool (http://heckyesmarkdown.com) can be scripted and Brett has a Ruby script (https://gist.github.com/ttscoff/2960951) that you can use to call it.

I've successfully used this before by writing a shell script to call Brett's Ruby script to convert a folder full of over 500 HTML files into Markdown and extract the text from them.

1
  • That looks like a really handy service, thanks for pointing it out. I like Markdown a lot but it seems this could be more complicated than just installing a third party wysiwyg instead of using the native RTE or native textarea formats. May 22, 2014 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.