How to store lightweight formatting (Textile, Markdown) in database?

前端 未结 4 431
故里飘歌
故里飘歌 2021-02-01 21:28

I\'m going to be implementing a lightweight formatting language (probably Textile, maybe Markdown) in a project I\'m working on, and I\'m wonder how best to store it in the data

相关标签:
4条回答
  • 2021-02-01 21:35

    You should definetly store original Textile/Markdown markup and use either standard HTTP caching stuff (Last-modified, Expires-At, ETag) to cache rendered pages or just cache the result of processing markup.

    0 讨论(0)
  • 2021-02-01 21:37

    Store markdown:

    • Every view = conversion
    • Every edit = no processing

    Store html

    • Every view = no processing
    • Every edit = convert to markdown and back

    Store both

    • Every view = no processing
    • Every edit = convert to html after edit

    You have to weigh up your processing costs vs. your storage cost.

    0 讨论(0)
  • 2021-02-01 21:48

    I'm currently using Markdown with PHP. I store the markdown-source in the database, and I display the Converted Version upon request. I have no performance issues, and am very happy with this setup.

    0 讨论(0)
  • 2021-02-01 21:53

    What I've seen is indeed to store the compiled HTML in a seperate row in the database. Just have one row 'content' and another 'content_html', and save the compiled HTML in the 'content_html' row.

    (Surely you have some kind of save method that you can override to do this?)

    0 讨论(0)
提交回复
热议问题