Rebake / Rebuild HTML not creating new HTML from markup

(brett) #1

Hi, I am importing an old forum using the json importer. The post body is imported via the ‘raw’ field.
I see that all of the formatting is off. All linefeeds and emojis are missing. Line feeds are just in raw as \n

When I look at the cooked data. It is the same as the raw.

  • If i ‘edit’ the post as an admin, the editor and the preview window shows the formatting correctly. I am guessing because I am editing in markdown mode and the preview window is just a markdown previewer.
  • If I save that post the newly edited post , the post is still wrongly formatted, has no linefeeds etc as before.
  • If I copy the text for the post while editing, and paste that into a new reply, the new reply is formatted correctly.

Here is the json from the post that is formatted incorrectly

cooked: “Yo Brett,\n\nermm, okay okay its the better Messageboard\nbut it looks like … well, you know ;-D\n\nRegards,\nOliver\n\nps: Change the colors \n (look in the stylesheet)”

Here is the json from the reply I made from simply copying the text from the edit window and making it a new reply.

cooked: “<p>Yo Brett,</p>\n<p>ermm, okay okay its the better Messageboard<br>\nbut it looks like … well, you know ;-D</p>\n<p>Regards,<br>\nOliver</p>\n<p>ps: Change the colors<br>\n(look in the stylesheet)</p>”

I have tried ‘rebuild html’ on the imported post, but it does nothing, the cooked is the same as the raw
I have tried

$ rake posts:rebake
Rebaking post markdown for ‘default’
76 / 76 (100.0%)
76 posts done!

but the cooked is still the same as the raw.

Is there anything I have to do to the imported raw to make sure it converts to html correctly? Is it guaranteed to execute a rebake immediately after the script is run? I only have 10 topics in this import as a test, it is not large.

(brett) #2

looking at import_scripts/json_generic.rb I see this

      topic = {
        id: t["id"],
        user_id: user_id_from_imported_user_id(username_for(first_post["author"])) || -1,
        raw: first_post["body"],
>>>>>   cook_method: Post.cook_methods[:raw_html],
        title: t['title'],
        category: t['category_id'],
        custom_fields: { import_id: "pid:#{first_post['id']}" }

Should :raw_html be changed to another constant?

edit: I changed raw_html to ‘regular’ and now it works.