question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrating content to mobiledoc format - parsing html server side

See original GitHub issue

Hi! Is there a way to parse existing html to mobiledoc format server side? I want to migrate my content to mobiledoc format.

In node.js I was trying to do something like this:

const parser = require('../mobiledoc-kit/dist/commonjs/mobiledoc-kit/parsers/html').default;
const builder = require('../mobiledoc-kit/dist/commonjs/mobiledoc-kit/models/post-node-builder').default;
const p = new parser(builder);
p.parse('<p> hello </p>');

but it requires browser environment (error: ReferenceError: document is not defined);

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
zfostercommented, Jun 27, 2018

Hey @kmoskwiak. It took a little bit to make this generic. The index.js file can be what you run or loop through for your content, but that is the entry point. We create a dom context and let Mobiledoc do its thing after sanitizing the html to remove tags that aren’t supported (think <small>). Happy to help, I haven’t tried to run through this gist and renamed some things so there may be a few errors, so let me know if I need to make any corrections.

A little side note: Our refetchMediaCards is just a function that calls GraphQL mutations to rehost images or fetch embeds to match the oembed spec. You can do anything there, so I didn’t include that file.

https://gist.github.com/zfoster/20744c3377d2582e503ce67cb0a464ab

0reactions
ErisDScommented, Oct 11, 2018

The Mobiledoc standard is awesome and we want to be able to easily move people from other platforms to using it. This requires conversion from HTML -> Mobiledoc and so I’ve been working on what I think is a simpler approach.

I have a WIP package here: https://github.com/TryGhost/Ghost-SDK/tree/master/packages/html-to-mobiledoc, but I’m running heavily into https://github.com/bustle/mobiledoc-kit/issues/648

Read more comments on GitHub >

github_iconTop Results From Across the Web

Html to mobiledoc from a .csv - Migrations - Ghost Forum
I have tried to install npm install “@tryghost/migrate -g” but it failed with a raft of deprecated links and things. The result is...
Read more >
github.com-bustle-mobiledoc-kit_-_2018-08-22_15-48-47
Mobiledoc Kit (beta) is a framework-agnostic library for building WYSIWYG editorssupporting rich content via cards.
Read more >
Document representation in JSON? - Discuss - ProseMirror
serializeTo) into JSON format (or text or markdown) and parse it back to PM ... server side and generate html there to render...
Read more >
Why We Left Medium for Ghost (and Not WordPress)
Now that we've finally completed our migration off Medium and onto a ... option is to export html files and parsing those files...
Read more >
开发工具 - 超级架构师
Avoids mutating data. Folktale - Suite of libraries for generic functional programming in JavaScript that allows you to write elegant, modular applications with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found