Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Qiita / Qiita:Team における Markdown レンダリングの歴史

Qiita / Qiita:Team における Markdown レンダリングの歴史

Markdown Night 2017 Summer
https://connpass.com/event/63383/

Yuji Nakayama

August 29, 2017
Tweet

More Decks by Yuji Nakayama

Other Decks in Technology

Transcript

  1. class Qiita::Markdown::Renderer < Redcarpet::Render::HTML # ... end renderer = Qiita::Markdown::Renderer(

    filter_html: true, hard_wrap: true ) parser = Redcarpet::Markdown.new( renderer, autolink: true, fenced_code_blocks: true ) html = parser.render(markdown)
  2. Redcarpet filter Emoji filter Syntax highlight filter Mention filter Markdown

    string HTML tree HTML tree HTML tree HTML tree HTML tree HTML tree HTML tree
  3. ࠶ϨϯμϦϯάػߏ w *ODSFNFOUBMͳSFOEFSFSWFSTJPO *OUFHFS Λఆٛ͢Δ w ϨϯμϦϯά݁ՌͷΩϟογϡʹɺͦͷ࣌఺ͰͷSFOEFSFSWFSTJPOΛҰॹʹ֨ೲ͓ͯ͘͠ w هࣄΫϥεͷϨϯμϦϯά݁ՌΛฦ͢ϝιου಺ͰɺΩϟογϡͷSFOEFSFSWFSTJPO͕ݱ ࡏͷWFSTJPOΑΓ΋ݹ͍৔߹͸ࣗಈతʹ࠶ϨϯμϦϯάΛ࣮ߦ͢Δ

    w ࣮ࡍʹ͸શϦΫΤετͰ࠶ϨϯμϦϯά͕૸Δͱෛՙͷ໰୊͕͋ΔͷͰɺ֬཰తʹ࣮ ߦ͞ΕΔΑ͏ʹ͠ɺ࣌ؒͱڞʹ཰Λঃʑʹ্͍͛ͯ͘ w RJJUBNBSLEPXOʹखΛՃ͑ͨ৔߹΍ɺԿΒ͔ͷཧ༝Ͱશهࣄͷ࠶ϨϯμϦϯάΛ࣮ߦ͠ ͍ͨ৔߹͸SFOEFSFSWFSTJPOΛ ͢Δ
  4. class Article < ActiveRecord::Base CURRENT_RENDERER_VERSION = 3 def rendered_body if

    cached_body_renderer_version < CURRENT_RENDERER_VERSION self.cached_body = render(markdown_body) self.cached_body_renderer_version = CURRENT_RENDERER_VERSION end cached_body end end