# How to create self-parsing HTML file?

**URL:** <https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059>\
**Category:** Implementation\
**Created:** [March 28, 2016, 9:48pm UTC](https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059 "2016-03-28T21:48:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johncj](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/a3d4f5/32.png) [@johncj](https://talk.commonmark.org/u/johncj)\
**Post date:** [March 28, 2016, 9:48pm UTC](https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059/1 "2016-03-28T21:48:24Z")

</div>

I have successfully installed Commonmark.js through the NPM and successfully can convert `md` files to HTML, this way:

```
commonmark test.md > test.html

```

Okay.

And after that, I tried to create this HTML file:

```
<script src="commonmark.js"></script>
<script type="text/javascript" src="commonmark.js"></script>

# header

text

text

```

(Also I previously downloaded javascript file itself and placed it together with HTML).

But when I open this file in web browser, I see just not formatted HTML:

```
# header text text

```

Instead of desired result:

> ![](https://cdn.commonmark.org/uploads/default/original/1X/0839a663b3a8dfe88f814fedb3f9d195260366ef.png)

What I’m doing wrong?

(There are no errors shown in Chrome Developer Tools).

I want it just for myselft. In other words, as replacement of Word. Open it with Sublime Text, write something, then open in Chrome and see the result. Something like [Strapdown](http://strapdownjs.com/). Maybe I’m on a wrong way?

---

<div class="post-metadata">

**Author:** ![chrisalley](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/chrisalley/32/906_2.png) [@chrisalley](https://talk.commonmark.org/u/chrisalley)\
**Post date:** [March 29, 2016, 3:38am UTC](https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059/2 "2016-03-29T03:38:16Z")

</div>

Including the Markdown in the HTML file directly won’t work because web browsers don’t understand Markdown natively. The browser is currently just treating the Markdown as plain text; you’ll need to tell the web browser how to use commonmark.js to render the Markdown as HTML so that the web browser can understand it (usually with a JavaScript function). You could look at the source code of the dingus for an example of how this is done.

---

<div class="post-metadata">

**Author:** ![johncj](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/j/a3d4f5/32.png) [@johncj](https://talk.commonmark.org/u/johncj)\
**Post date:** [March 29, 2016, 5:13pm UTC](https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059/3 "2016-03-29T17:13:02Z")

</div>

Thanks, Chris! Short and understandable answer.

---

<div class="post-metadata">

**Author:** ![xoofx](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/xoofx/32/1424_2.png) [@xoofx](https://talk.commonmark.org/u/xoofx)\
**Post date:** [March 29, 2016, 11:10pm UTC](https://talk.commonmark.org/t/how-to-create-self-parsing-html-file/2059/4 "2016-03-29T23:10:17Z")

</div>

[Markdeep](http://casual-effects.com/markdeep/) is using this technique, though It’s not CommonMark compliant
