Migrating content to mobiledoc format - parsing html server side
See original GitHub issueHi! 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:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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
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