Mobiledoc Validator to fix Mobiledoc

So this is not something broken in Ghost itself but something I broke by myself.

I migrated my blog from Wordpress to Self-hosted Ghost and the content was really ill-shaped. The only option was to manually go to each post and fix it. I tried for many of my posts; though it was getting tiring.

Then I realized; it’s all in DB, so OI started writing small queries to replace certain pieces in MobileDoc column in posts.

I learned that I should have not done it.

Now the Konig editor fails to render as the mobile doc kit in vendor.js is throwing errors.

Now I have no option but to find a way to fix the mobiledoc. In the end, it’s gonna take very very long then it would have taken to go and fix each post.

I am seeking some suggestion from the Editor developers here about what can be done to resolve it a bit more faster.

Few ways I can think of are

  • convert the post to mobiledoc and save it again
  • validate the mobiledoc and find out what’s broken and fix it in the same way it was broken

Please suggest.

So found the exact issue in the mobiledoc

I had replaced the “strong” in the markups area of mobiledoc; I revisited the post and checked in the generated HTML about what must be there.

And did a simple query as:

UPDATE posts
SET mobiledoc = REPLACE(mobiledoc, '],[],[', '],["strong"],[')
WHERE mobiledoc LIKE ("%],[],[%");

So far the issue is fixed.

Though thanks to this issue; I got to get more familiar to mobiledoc format for Rich Text Editing

Came across GitHub - joshfrench/react-mobiledoc-editor: A Mobiledoc editor written with React and Mobiledoc-Kit. that I might wanna use in future to make my own editor for articles.

Thanks :slight_smile:

Eeesh, I totally feel your pain. Migrating from WP is very challenging at the moment.

I was gonna write and say there isn’t really a validator - although it’s an interesting idea.

But super glad you got this sorted out!

2 Likes

TBH, I thought I would need to recreate my site because of this issue. Though I am also glad that the fix was simple.

Validator is really great idea. I checked all the docs for mobiledoc and it is so hard to follow it, as it is based on Array index rather than keys.

Then I was thinking, what if there is similar mobiledoc with keys rather than array index. And no specific assignment for 0 for atom and 1 for card etc. but being more explicit JSON definition/schema to build the content.

What do you think @Hannah ?