Is there a ways to convert a markdown file to HTML from the command line? Or even better, a directory of markdown files?
This would allow us to store documentation in Git, and automatically render it to HTML so people without Atom & this plugin can still see the result.
(The plugin is amazing btw!)
Hi @Timmmm ,
Right now command-line export is not supported.
I don't have a plan to implement command-line support, but I will let you know if I decide to support.
Thank you
Ok. If I wanted to implement this, can you give me a rough guide of how to do it? Is the rendering part of the library well separated from Atom? Can it be extracted into a standalone program? (That would be extra awesome because then I can make a Stash plugin for it.)
Yes it is possible, but will be hard because some parts are related to MarkdownPreviewEnhancedView class.
You may need to read through the following files:
My code is actually messy, so ask me if you meet any problem.
Thank you.
+1
@Timmmm please let me know when you start to work on this.
I was thinking to make a web based wiki, use the same file format with markdown-preview-enhanced.
We decided not to use it in the end. We were thinking of having
documentation in a git repo, and automatically rendering it. But some other
people really wanted to use Confluence so we are going with that and using
its PlantUML plugin. Not as nice IMO but I am not the boss unfortunately.
On 13 November 2016 at 16:47, Wang Xu [email protected] wrote:
+1
@Timmmm https://github.com/Timmmm please let me know when you start to
work on this.
I was thinking to make a web based wiki, use the same file format with
markdown-preview-enhanced.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/shd101wyy/markdown-preview-enhanced/issues/181#issuecomment-260197404,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAXACv3cg4EGjdeayNubvIiil4M8UMtOks5q9z8ngaJpZM4Kl6N4
.
+1
I think that a cli driven export would be a killer feature!
By now I have to rely on pandoc for an automated "build" of all my md docs :) but I'm missing many cool features (i.e. the awesome "@import") Do you have any hint on how to use pandoc (or similar) to batch translate markdown to html with that feature?
I would recommend you to check mume project, which powers the markdown preview enhanced package.
You can use that library to build command line tool.
oh gosh! Exactly what I was looking for! Awesome.
@aerophagiano, did you implement a CLI using Mume? I would be interested in having a look at it for my own use, if possible.
OK, I got mume to work for automatic processing of my Markdown.
I wrote some Javascript to process all of the .md files in the current folder. I run this script via Visual Studio Code's tasks functionality.
It produces the same output as when I manually output HTML (offline) from Markdown Preview Enhanced.
Code below (improve it if you want to):
``` javascript
// node.js
const mume = require('C:/src/mume-lib/node_modules/@shd101wyy/mume'); //This is the path where I downloaded the mume libraries - modify this to suit your own path
// es6
// import * as mume from "@shd101wyy/mume"
async function main() {
await mume.init();
const engine = new mume.MarkdownEngine({
filePath: "Help.md",
config: {
previewTheme: "github-light.css",
codeBlockTheme: "default.css",
printBackground: false,
enableScriptExecution: true, // <= for running code chunks
},
});
var fs = require('fs');
var path = '.'; //current folder
var mdextension = '.md';
try {
var mdfiles = fs.readdirSync(path);
if (typeof mdfiles !== 'undefined' && mdfiles.length > 0) {
for(var i=0; i < mdfiles.length; i++)
{
var mdindex = mdfiles[i].indexOf(mdextension, (mdfiles[i].length - 3)); //only check that the last 3 character match the '.md' file extension
if (mdindex !== -1)
{
console.log('Processing: ' + mdfiles[i]);
engine.filePath = mdfiles[i];
// html export
await engine.htmlExport({ offline: true, runAllCodeChunks: true });
}
}
}
}
catch(e)
{
console.log(e.name + ': ' + e.message);
}
return process.exit();
}
main();
``
Most helpful comment
I would recommend you to check mume project, which powers the markdown preview enhanced package.
You can use that library to build command line tool.