parcel-plugin-markdown-string
parcel-plugin-markdown-string copied to clipboard
following README for getting HTML string didn't work for me
I only got markdown when I was trying to get HTML. By putting console.log
statements in the code, I noticed that the default config had:
{ marked: undefined, html: undefined }
I ended up just doing an asset transformation, which is what originally looking for. Would be nice if how to do that were more clearly explained in the README. Here's the example I came up with that seems to work for me: https://github.com/ultrasaurus/hello-parcel-markdown/tree/simple-asset-transform
basically, just needed to add .markedrc
with
{
"marked": true,
"html": true
}
then `yarn parcel src/index.md`
https://github.com/jaywcjlove/parcel-plugin-markdown-string/blob/64abbf6862b9148e651277bce6230f9189dc4b97/example/.markedrc#L1-L12
@ultrasaurus
Another change that seems to be required is using the bundle-text:
protocol to import the rendered markdown as a string:
import HTMLStr from 'bundle-text:./Markdown.md';
console.log(HTMLStr) // => Output HTML string.
document.body.innerHTML = HTMLStr;
This is the first time I see such an import, is there any documentation for my reference? @comp500
~~See https://parceljs.org/features/bundle-inlining/#inlining-a-bundle-as-text~~
Nevermind, this isn't required. I'm not sure why it wasn't working before...