Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Markdown を拡張する話

Markdown を拡張する話

at Markdown Night 2017 Summer

Koutarou Chikuba

August 29, 2017
Tweet

More Decks by Koutarou Chikuba

Other Decks in Technology

Transcript

  1. ୭޲͚ͷൃද͔ • ԿΒ͔ͷࣄ৘Ͱ markdown Λ֦ு͠ͳ͚Ε͹ͳΒͳ͍ਓ • AST ͕޷͖ͳਓ • GFM/Commonmark

    ͷ࢓༷ΛकΔ੓࣏తਖ਼͠͞ͱ͔ɺ͜ͷൃද ͷதʹ͓͍ͯ͸Ͳ͏Ͱ΋͍͍…
  2. Τοδέʔεͷྫ - a - b - c -d - e

    https://babelmark.github.io/?text=-+a++++-+b++-+c+ ++-d+-+e
  3. 2. ֦ு͢ΔͳΒߦّΑ͘ • GFM ͷ fenced codeblock ͷத਎ΛͲ͏ग़ྗ͢Δ͔͸࣮࣭ ࣗ༝࿮ •

    ϦςϥϧΛ֦ு͢Δ৔߹ɺGFMͰ΋ະ࢓༷ͷϦςϥϧΛ࢖͏($ %) • جຊ͸ࣗ༝هड़ͱ͍͏ͷΛ๨Εͳ͍Α͏ʹ
  4. ྫ: ਺ࣜϦςϥϧ֦ு $ x^2 + y^2 = z^2 $ •

    $ ~ $ Λ math ϊʔυͱͯ͠ύʔε • Khan/KaTeX ͰίϯύΠϧͯ͠ຒΊࠐΉ ͱ͔͍ͨ͠
  5. JS ͷ Markdown ॲཧܥ • chjj/marked • egoist/marked3 • showdown

    • markdown-js • wooorm/remark <- ͓͢͢Ί
  6. remark • github.com/wooorm/remark • wooorm ࢯ͸ࣗવݴޠॲཧͷݚڀऀɻ ଞɺ retext ͳͲ •

    ๛෋ͳϓϥάΠϯ: https://github.com/wooorm/ remark/blob/master/doc/plugins.md • GFMΦϓγϣϯɺ CommonmarkΦϓγϣϯ͕͋Δ
  7. remark: ϓϥάΠϯͷྫ • remark-react: MarkdownAST => React • remark-lint: Style

    Linter • remark-emoji: emoji֦ு • remark-lowlight: ίʔυͷγϯλοΫεϋΠϥΠτ • remark-inline-math: ਺֦ࣜு • remark-toc: ToCੜ੒
  8. remark: ΤίγεςϜ • unist: Universal AST • mdast: Markdown AST

    • hast: HTML AST ͦΕͧΕͷஈ֊͝ͱʹద༻Մೳͳ plugin ܊
  9. mdast https://github.com/syntax-tree/mdast • Markdown ͷ AST ఆٛ • unist αϒηοτ

    • ࣮૷͸ https://github.com/wooorm/mdast-util-to- hast
  10. hast https://github.com/syntax-tree/hast • HTML ͷ AST ఆٛ • ͜ͷ૚ͷར఺ͱͯ͠ɺ hast

    => HTML ΍ hast => React ͷந৅͕Ͱ͖Δ • αχλΠβͳͲ΋͜ͷ૚Ͱ࣮૷
  11. draft-js Ͱ markdown Λ૬ޓม׵ • draft-js: Facebook੡ͷWYSIWYGج൫ • draft-js-import-markdown Ͱ

    markdown Λೖྗ • draft-js-export-markdown Ͱ markdown Λग़ྗ
  12. ͜ͷํ๏ͷ໰୊ • draft-js ͷ WYSIWYG ͷϓϨϏϡʔ࣮૷ͱ Markdownग़ྗ ͷʮݟͨ໨ʯΛ͋Θͤͳ͍ͱ͍͚ͳ͍ • A

    => B => A ͕Մٯ͔͸ผͷ໰୊ • draft-js ͷ࣮૷ͱ֦ு͕݁ߏਏ͍ (immutable.js ͷਂ͍ ཧղ͕ඞཁ) ͍ͣΕ΋ʮؾ߹ʯͰղܾ͢Δ͕…
  13. ଞͷҊ • slate.js: draft-js ͷ alternative • prosemirror: ·͞ʹ markdown

    <=> wysiwyg ͕֦ͩு ੑ͕௿͍ • markdown ͦͷ΋ͷʹϋΠϥΠτΛ͢Δ + ೖྗࢧԉ
  14. ͓·͚2: Node.jsӡ༻ͷ໰୊ • SEOॏࢹͷ৔߹ɺ JS࣮૷ͩͱ React ͷ Server Side Rendering

    ͱಉ͡ɺͲ͜ͰNodeϓϩηεΛ؅ཧ͢Δ͔ͷ໰୊ ͕ൃੜ • NodeϓϩηεΛͿΒԼ͛Δ͔ɺ AWS Lambda ্ͷϚΠΫϩα ʔϏεʹͯ͠͠·͏͔
  15. ͓·͚5: Kobito for Windows ͷ࣮૷ • codemirror ͷ markdown ϋΠϥΠτϞʔυ

    • codemirror ͷίʔυ͕෗ͬͯͯਏ͍ • γϯλοΫεϋΠϥΠλʔ͕Ͱ͔͍໰୊ΛҾ͖ͣͬͯͯ 1.5MB ͋Δ https://github.com/increments/kobito-oss/tree/ master/packages/markdown-editor