Skip to content Skip to sidebar Skip to footer

How To Write Markdown Language In HTML Language?

# (and ## and ###) in md files has the meaning of header 1 (2, 3). This md (markdown) header is used by a table of content widget I developed. I want to use a md header (written as

Solution 1:

You can use marked package for that. Example:

$(document).ready(function(){
  var content = $('.my-md').html();
  $('.my-md').html(marked(content));
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/0.3.6/marked.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<div class="container">
 <div class="my-md">
# Hello world
This is ** a simple test ** .
  </div>
</div>
 

Post a Comment for "How To Write Markdown Language In HTML Language?"