Enable your site to support Markdown

Source: Internet
Author: User

Get Showdown.js, which is required to change the style JS

This is their github, Https://github.com/showdownjs/showdown.
But let's use the introduced Bootcdn showdown.min.js.
http://www.bootcdn.cn/showdown/

Introduction to the settings in the Web site HTML
<script src="https://cdn.bootcss.com/showdown/1.8.6/showdown.js"></script>

Our article is in a div with ID Postcont

<!--文章内容开始-->    <div id="postcont" style="white-space: pre">文章内容</div>    <script>    var converter = new showdown.Converter();    var post      = document.getElementById('postcont');    var  text      = post.textContent||post.innerText;//获取文本内容, post.textContent是非ie所用,post.innerText是ie所用,    var html      = converter.makeHtml(text);          //这里写成这样是为了兼容    post.innerHTML=html;    </script>    <!--文章内容结束-->

Effect:

Enable your site to support 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.