DenReg/markdown
Fabian Stamm 1b2d85eeef
continuous-integration/drone/push Build is passing Details
Adding hotfixes for packages
2020-10-14 02:56:11 +02:00
..
.vscode Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
src Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
LICENSE Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
README.md Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
example.html Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
example.md Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
md2html.ts Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
meta.json Adding hotfixes for packages 2020-10-14 02:56:11 +02:00
mod.ts Adding hotfixes for packages 2020-10-14 02:56:11 +02:00

README.md

markdown

Deno Markdown module forked from bb47aa8e62

Example usage

Simple md2html.ts script:

import { Marked } from "./mod.ts";

const decoder = new TextDecoder("utf-8");
const filename = Deno.args[0];
const markdown = decoder.decode(await Deno.readFile(filename));
const markup = Marked.parse(markdown);
console.log(markup.content);
console.log(JSON.stringify(markup.meta))

Now running:

deno run --allow-read md2html.ts example.md > example.html

Will output:

<h1 id="hello-world">Hello World</h1>
<h2 id="this-an-example-for-md2html-ts-">
  This an example for <code>md2html.ts</code>
</h2>
<p>A small paragraph that will become a <code>&lt;p&gt;</code> tag</p>
<hr />
<p>Code Block (md2html.ts)</p>

<pre><code class="lang-typescript">import { Marked } from &quot;./mod.ts&quot;;

const decoder = new TextDecoder("utf-8");
const filename = Deno.args[0];
const markdown = decoder.decode(await Deno.readFile(filename));
const markup = Marked.parse(markdown);
console.log(markup.content);
console.log(JSON.stringify(markup.meta))
</code></pre>
<p>
  This module is forked from
  <a
    href="https://github.com/ts-stack/markdown/tree/bb47aa8e625e89e6aa84f49a98536a3089dee831"
    >ts-stack/markdown</a
  >
</p>
<p>Made for Deno <img src="https://deno.land/logo.svg" alt="deno-logo" /></p>

{"title":"Hello world!","subtitle":"Front-matter is supported!","boolean":true,"list-example":["this","is",{"a":"list"}]}

Notes

I had to do some changes to the source code to make the compiler happy, mostly fixes for things that were uninitialized and possibly null or undefined