How to render markdown text to the page?

Source: Internet
Author: User
The original markdown text is stored in the data, and now you want to read the browsing page? How to render? Convert it to html format and then put it on the terminal page? Or directly put the markdown text on the front-end page, and then use the js rendering function to render it into formatted text. Either way, the user reads the original markdown text in the data and then reads the browser page? How to render?

  1. Convert it to html format and then put it on the terminal page?

  2. Or directly put the markdown text on the front-end page, and then use the js rendering function to render it into formatted text.

Either way, the user must see formatted text, but the source code of the webpage should be all html in the first way, and the content of the Subject displayed in the source code in the second method should be markdown text, not html text

Which method is better? Only read from the database to the front-end display (I use bootstrap-markdown)

Reply content:

The original markdown text is stored in the data, and now you want to read the browsing page? How to render?

  1. Convert it to html format and then put it on the terminal page?

  2. Or directly put the markdown text on the front-end page, and then use the js rendering function to render it into formatted text.

Either way, the user must see formatted text, but the source code of the webpage should be all html in the first way, and the content of the Subject displayed in the source code in the second method should be markdown text, not html text

Which method is better? Only read from the database to the front-end display (I use bootstrap-markdown)

The rendering process is handed over to the front-end for completion ......

InTypechoIs usedPHPRendered and displayed to the user.

In fact, js rendering or background language rendering are optional.

It depends mainly on the specific problems and functions.

For a blog, using these two methods does not matter much.

You have misunderstood the subject. The content that the browser can present or render must comply with the webpage specifications: html and css

The content of markdown cannot be understood by the browser. You need to use the md parsing library to convert the content of md into the tags and styles required by the browser.
For example, "# Title" in markdown is "", and the display effect is as follows:

Title

What the parser does is to talk about your md text "# Title" and convert it into a tag that the browser can understand ""
So what you need is a Markdown Parsing Library, for example: parsedown

Second, how do you modify the first one?

Only the markdown format is retained. You can parse the output or use js to parse the output.

Search for questions.

A certain degree and Google can produce dozens of pages of results.

You can also search in the Community first. This is also a bad question.

Refer to another question on this site:

Http://segmentfault.com/q/1010000004113131

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.