The choice of markdown

Source: Internet
Author: User
Tags html header

Direct hit scene

I've been thinking about what format to use to store documents better. have been using Google Docs, but its format is not public, upload/download need to convert the format, the conversion will inevitably lose some information. Then thought, that is still pure text or markdown bar.

But Markdown dialect a lot, choose which good? I examined the following three.

    1. Pandoc. John Macfarlane wrote the Universal converter. One drawback to me is that it's the Haskell language.

    2. Commonmark. This is a great attempt by John Macfarlane to standardize the markdown. He gives the C language and JS implementation, where the C language is easy to compile in Windows, the code is easy to understand. Unfortunately, no one bought it.

    3. GitHub flavored Markdown. This is probably the standard of fact now. Because the code is hosted on GitHub, it naturally follows GitHub's requirements when it comes to writing documents. I didn't find it in the open source implementation. However, Atom.io is a github company, and the markdown implementation of this editor is marked. I tried it and it was good.

So I took marked as an example and wrote a simple script to convert the markdown file to HTML

var marked = require (' marked ');  var fs = require (' FS ');  var inputfilename=process.argv[2];  var outputfilename=inputfilename.replace ('. MD ', '. html ');  Console.log ("Processing" +inputfilename);  var markdownstring=fs.readfilesync (inputfilename, "UTF8");  Marked.setoptions ({highlight:function (code) {return require (' Highlight.js '). Highlightauto (code). Value;  }}); htmlbody=marked (markdownstring); Html= "<! DOCTYPE html><Html><Head><Metahttp-equiv=\ "Content-type\"Content=\ "Text/html; charset=utf-8\ ">\n" + "< Link rel=\ "stylesheet\" href= \ "Https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/ styles/default.min.css\ ">\n" + "</head><body> "+htmlbody+" </< Span class= "title" >body></html> "Fs.writefilesync (outputfilename , html,{encoding: "UTF8"});  

In the HTML header plus a line of Mathjax JS Link, you can support the mathematical formula in the markdown.

The choice of markdown

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.