4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MiddlemanでMarkdownでpre要素を使う時に出てしまう余分な余白を消す方法

Posted at

Markdownでcodeのsyntax-highlightを使いたいときにハマった。
まず、RedCarpet か Kramdownを使う場合、config.rbに下記のようにMarkdown Engineをsetする。

set :markdown_engine, :redcarpet
set :markdown, :fenced_code_blocks => true, :smartypants => true

## OR

set :markdown_engine, :kramdown

ERBやSlimでは上記のsetのみでpre要素は通常にレンダリングされるが、
テンプレートエンジンにHamlを使う場合は、複数行のコードをpreに入れると二行目以降で無駄な余白が入る。
余白を消す為に、config.rbに下記をsetすると解消される。

set :haml, { ugly: true }
4
4
0

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
4
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?