When is Markdown generally parsed?

Source: Internet
Author: User
Currently, I am using github. comerusevparsedown to parse Markdown. There are two options: 1. parsing before inserting the database 2. Better to parse the output. Now I am using a https://github.com/erusev/parsedown to parse Markdown.

There are two options:
1. parsing before database insertion
2. Output Parsing

Which is better?

Reply content:

Currently I am using a https://github.com/erusev/parsedown to parse Markdown

There are two options:
1. parsing before database insertion
2. Output Parsing

Which is better?

Parsing at output time. By the way, if pseudo-static files are available, real static files can be generated, so that the html generated will be requested next time, and the database will not be read and the parsing process will be followed, when updating data, you only need to delete the original static file and re-generate the file by triggering the access again.
You can useCache (the simplest File Format)Method, first detection when accessingcacheWhether the directory contains the corresponding html file that has been generated. If yes, the file is output directly. when data is updated in the background, the file is deleted.cacheOr directly clear the corresponding files in the directory.cacheDirectory, which will be generated again during the next access.

Use frontendjsPairMarkdownTo parse the content, the browser needs to load the correspondingjs,jsTo complete the conversion, it takes time in the middle, and the page loading needs to be parsed.MarkdownJs file (one moreHTTPRequest), instead of generating the correspondinghtmlFile. It will be used directly next time.
And you don't have to consider whether the browser supports js :)

Of course, it is parsed during output (it can be cached)
What should I do if you want to edit it before parsing it into the database?
I reversed it again?

The overall consideration is of course two copies. One copy for md and one copy for parsing. Take the parsed copy for the presentation.
Of course, the output will also be parsed. However, the bottleneck of computer resources is generally in computing power. Why is it a waste of presentation.

Parse the outputmarked.jsYou can.

You can also consider front-end resolution.

If the parsed data is stored, the original text cannot be edited as described in another answer.
If two copies are saved, the synchronization will take up more space.
In front-end parsing, these problems do not exist. In any case, the front-end should also look at the preview version during editing. It is better to put all the work on the front-end, and the back-end should only save the original.

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.