Categories
JavaScript Answers

How to include markdown (.md) files inside HTML files?

Spread the love

Sometimes, we want to include markdown (.md) files inside HTML files.

In this article, we’ll look at how to include markdown (.md) files inside HTML files.

How to include markdown (.md) files inside HTML files?

To include markdown (.md) files inside HTML files, we can use the zero-md web component.

For instance, we write:

<script type="module" src="https://cdn.jsdelivr.net/gh/zerodevx/zero-md@1/src/zero-md.min.js"></script>

<zero-md>
  <script type="text/markdown">
    # **This** is my [markdown](https://example.com)
  </script>
</zero-md>

We add the zero-md web component with a script inside that contains the Markdown code.

It’ll be rendered if we set the type attribute to text/markdown.

Conclusion

To include markdown (.md) files inside HTML files, we can use the zero-md web component.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *