LoginSignup
34
31

More than 5 years have passed since last update.

Qiita::Markdownを使う on Yosemite

Posted at

TL;DR

install

gem 'qiita-markdown'
% budle install

Native Extensionsのbuildに失敗したら、各種依存ライブラリを準備する必要がある。

charlock_holmes

build失敗メッセージに従い、Homebrewで icu4c をインストールする。

% brew install icu4c

rugged

Homebrewで cmake をインストールする。

% brew install cmake

nokogiri

emojiを準備する

diff --git a/Rakefile b/Rakefile
index 2cea5c9..64965dc 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,4 +1,5 @@
 require 'rake/testtask'
+load 'lib/tasks/emoji.rake'

 task :default => :test
  • bundle exec rake emoji
  • public/images/emoji 以下に画像ができる
  • Rails Appの public/images 以下に移動

qiita-markdowngemoji に依存しているので、gemのディレクトリに移動して作業してもよい。

usage

# processorを準備(このとき必要ならオプションを渡す)
processor = Qiita::Markdown::Processor.new
# markdown : renderしたいmarkdown文字列
result = processor.call(markdown)
# html-pipelineのHTMLツリーをHTMLに
output = result[:output].to_s
# viewに出力
output.html_safe
34
31
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
34
31