How do I keep markdown text in the database?

Source: Internet
Author: User
Users through the browser submitted markdown format of browsing, PHP will be in the original markdown format saved to the database ... What does PHP do with the user input in this process? In particular, the user input HTML code, how the original code display.

Add: The database is the original MD text, my question is to store to the database, the user input of the MD How to deal with?

Reply content:

Users through the browser submitted markdown format of browsing, PHP will be in the original markdown format saved to the database ... What does PHP do with the user input in this process? In particular, the user input HTML code, how the original code display.

Add: The database is the original MD text, my question is to store to the database, the user input of the MD How to deal with?

This one, you have to pay attention to two points:

1. Data validation before storage, keep in mind that all user input content is not trustworthy. Remember!!!

2. Visually you want to display this content on the page, you can't show it directly ... What you have to show to the user is the MD converted to HTML format in order to be friendly! Oh, yes.

In view of the above two points: can go to a website: https://packagist.org/

Search markdown : You will find a lot of wheels ~ Of course, you have to use composer ~ What? You said you didn't use this? Why isn't?

  • With a markdown parser, the top of the page shows the markdown format of the edge display has been resolved

  • Save two when you save a database

  • Remove the saved markdown when you need to update

  • Output the saved HTML directly when you want to see it

  • 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.