Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
LaravelでMarkdownをブラウザに表示する方法
Search
SAW
October 30, 2019
Programming
0
1.3k
LaravelでMarkdownをブラウザに表示する方法
Web×PHP TechCafe 10月 の発表資料です。
SAW
October 30, 2019
Tweet
Share
More Decks by SAW
See All by SAW
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Provide/Inject で TypeScript の恩恵を受ける方法
azuki
3
84
GraphQL はいいぞ! ~Laravel で学ぶ GraphQL 入門~
azuki
1
240
OSS contributor への第一歩を踏み出すまでの物語
azuki
1
170
Eloquent で relation を扱う基礎
azuki
0
97
メイキング・オブ・PHPカンファレンス 〜PHPカンファレンス関西2024の運営スタッフが語る舞台裏〜
azuki
0
61
ブラウザでテキストを読み上げる
azuki
0
110
計画性ないけれどノリと勢いだけで地方でも勉強会を開くすゝめ 〜 PHPカンファレンス関西2024 の懇親会 LT のその後 〜
azuki
0
55
GraphQL 入門
azuki
1
110
Other Decks in Programming
See All in Programming
CSC509 Lecture 12
javiergs
PRO
0
160
Webの技術スタックで マルチプラットフォームアプリ開発を可能にするElixirDesktopの紹介
thehaigo
2
1k
Better Code Design in PHP
afilina
PRO
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
1
100
RubyLSPのマルチバイト文字対応
notfounds
0
120
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
Contemporary Test Cases
maaretp
0
130
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
120
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
290
役立つログに取り組もう
irof
28
9.6k
NSOutlineView何もわからん:( 前編 / I Don't Understand About NSOutlineView :( Pt. 1
usagimaru
0
330
Featured
See All Featured
BBQ
matthewcrist
85
9.3k
Navigating Team Friction
lara
183
14k
Building Your Own Lightsaber
phodgson
103
6.1k
A Philosophy of Restraint
colly
203
16k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Fireside Chat
paigeccino
34
3k
Faster Mobile Websites
deanohume
305
30k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
GraphQLの誤解/rethinking-graphql
sonatard
67
10k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Transcript
-BSBWFMͰ.BSLEPXOΛ ϒϥβʹදࣔ͢Δํ๏ 8FCº1)15FDI$BGF 4"8
XIPBNJ w ࢯ໊Ճ౻फҰ ࡀ ‣ େࡕࡏॅɾѪग़ ‣ ϋϯυϧωʔϜ4"8
w 4/4ΞΧϯτ ‣ 5XJUUFS!B[VLJ@FBUFS ‣ (JU)VCB[VLJQFOHVJO w ॴଐגࣜձࣾ.4&/ 2 FreeBSD macOS Linux Vue.js
.BSLEPXOΛ)5.-ʹมͯ͠ૹ৴ w -BSBWFMͰ.BSLEPXOΛ)5.-ʹมͯ͠Ϗϡʔʹө͍ͨ͠ ‣ ྫ.BSLEPXOͰهࣄΛॻ͚ΔϒϩάγεςϜͷ࡞ w 1)1ͷ.BSLEPXOύʔαϥΠϒϥϦcebe/markdownΛಋೖ ‣ ෳͷ.BSLEPXOॻࣜʹରԠ
5SBEJUJPOBM(JU)VC.BSLEPXO&YUSB 3
1)1.BSLEPXOύʔαϥΠϒϥϦͷൺֱ w DFCFNBSLEPXO ‣ ରԠॻࣜ5SBEJUJPOBM(JU)VC.BSLEPXO&YUSB w 1)1.BSLEPXO ‣ ରԠॻࣜ5SBEJUJPOBM.BSLEPXO&YUSB w
1BSTFEPXO ‣ ରԠॻࣜ(JU)VC 4
DFCFNBSLEPXOͷಋೖํ๏ w $PNQPTFSܦ༝ͰΠϯετʔϧ ‣ composer require cebe/markdown w .BSLEPXOύʔαΫϥεΛಡΈࠐΈ ‣
cebe\markdown\Markdown.BSLEPXOͷύʔαΫϥε ‣ cebe\markdown\GithubMarkdown(JU)VCॻࣜͷύʔαΫϥε ‣ cebe\markdown\MarkdownExtra.BSLEPXO&YUSBॻࣜͷύʔαΫϥε 5
DFCFNBSLEPXOͷར༻ํ๏ w .BSLEPXOύʔαΫϥεͷಡΈࠐΈ ‣ use cebe\markdown\GithubMarkdown; w ύʔαΠϯελϯεͷੜ ‣ new
GithubMarkdown(); w )5.-ܗࣜʹม ‣ $parser->parse($markdown); 6 <?php use cebe\markdown\GithubMarkdown; public class Md2Html { public static function convert($md) { $parser = new GithubMarkdown(); return $parser->parse($md); } }
ม݁ՌΛϏϡʔʹө w #MBEFϑΝΠϧʹม༰ΛຒΊࠐΈ ‣ $parser->parse($md))5.-ܗࣜͷจࣈྻΛฦ٫ ‣ {!! !!}Ͱ)5.-ͷΤεέʔϓΛࢭ 7 <div>{!!
$html !!}</div> <div> <ul> <li>Laravel</li> <li>CakePHP</li> <li>FuelPHP</li> </ul> </div>
.BSLEPXOύʔαͷར༻ྫ w .BSLEPXOͰهࣄΛฤू͢ΔϒϩάγεςϜ 8 Laravel ฤू ߘɾϓϨϏϡʔ อଘ NE औಘ
NE ม IUNM ߘ༰ͷ Ϗϡʔ ΫϥΠΞϯτ %# औಘ NE ฤूը໘
ιʔείʔυྫ 9 class Article extends Model { public function getBodyAttribute($value)
{ $parser = new GithubMarkdown(); $this->attributes[‘body’] = $parser->parse($value); } } class ArticleController extends Controller { public function index(Request $req, $id) { $article = Article::find($id); return view(‘article’, [ ‘article’ => $article ]); } } <h1> {{ $article->title }} </h1> <article> {!! $article->body !!} </article>
·ͱΊ w 1)1ͷ.BSLEPXOύʔαDFCFNBSLEPXOͷհ ‣ ෳͷॻࣜʹରԠՄ w -BSBWFMͷಋೖํ๏ͱར༻ํ๏Λઆ໌ ‣ ରԠ͢Δ.BSLEPXOύʔαͷछྨ ‣
.BSLEPXO͔Β)5.-ม͢Δํ๏ 10
͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠