If you use Webpack (e.g. Electron React Boilerplate ), you can save a few steps using Webpack loaders.
npm i -D html-loader markdown-loader marked
In webpack.config.renderer.dev.js:
import marked from 'marked'; const markdownRenderer = new marked.Renderer(); .... // Markdown { test: /\.md$/, use: [ { loader: 'html-loader' }, { loader: 'markdown-loader', options: { pedantic: true, renderer: markdownRenderer } } ] }
Then, in the React component, this is just a requirement and customization of the HTML.
import knownIssues from '../assets/md/known-issues.md'; .... <p dangerouslySetInnerHTML={{ __html: knownIssues }} />
Finally, Flow will report an error (it still works) when importing a markdown file. Add this to .flowconfig to make Flow treat md files as string resources (taking care of Webpack):
module.name_mapper.extension='md' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
source share