简体   繁体   中英

How to display markdown content in browser (probably using markdown.js?)

I am new to javascript and html so this might be a newbie question. I need to provide users with a markdown editor and then show their input in a different webpage .

I have used Bootstrap-Markdown for the editor which has server my purpose beautifully for taking input from the user. Now I have included markdown.js in my project but cannot really figure out how to show the content to the user. Is the content supposed to be put as an iframe tag?

From the documentation :

 md_content = "Hello.\\n\\n* This is markdown.\\n* It is fun\\n* Love it or leave it." html_content = markdown.toHTML( md_content ); 

The markdown is supposed to be in a JavaScript string. You then use the library to convert it to HTML. Then you can add it to the DOM as normal.


For displaying content on a different webpage, you are probably best off using a server side markdown parser.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM