Aloha. So, I’m trying to extract approximately 9000 old blog and news posts from an overcustomized drupal 7 site to be custom imported to a custom ghost setup. All is almost well. They’re being parsed and imported and look good. Almost.
All references to the images are being removed by the @tryghost/html-to-mobiledoc parser. So I set up a quick listener doing nothing but interpreting HTML to try and test and… well…
const converter = require("@tryghost/html-to-mobiledoc");
const plugins = require("@tryghost/kg-parser-plugins");
const striptags = require('striptags');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
const port = 1701;
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/', (req, res) => {
if ( req.body.html ) {
console.log( 'body received' );
res.send(
JSON.stringify( converter.toMobiledoc( req.body.html, { plugins: plugins } ) )
)
} else {
res.status(400).send('must provide html field in the post');
}
});
app.listen(port, () => {
console.log(`Mobiledoc converter listening at http://localhost:${port}`)
});
I run that with node in one terminal, and then hit it with posts containing images…
% curl -d 'html="<img src=\"https://i.imgur.com/HVdC8fs.png\">"' -X POST localhost:1701
and get…
{"version":"0.3.1","atoms":[],"cards":[],"markups":[],"sections":[[1,"p",[[0,[],0,"\""],[0,[],0,"\""]]]]}
Basically… image? NOPE. No images for you! I must be doing something wrong. But it’s not clear what. It just rejects my effort with a big smile. Heh.
Insights?