2
2

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.

AsciiDocで吹き出し付きブロック要素の下に別のリストを作るTips

Posted at

AsciiDocで文書を書く際に、リストをセクション代わりに使ってソースの説明をすると……

test.adoc
* intの例

[source,java]
----
public class Main{
  public static void main(String []args){ //<1>
    int i = 0; //<2>
    i++; //<3>
    System.out.println(i); //<4>
  }
}
----
<1> メインメソッドを作成します
<2> `int` 型の変数を初期値 `0` で定義します
<3> 2の変数の値を `1` 足します
<4> 2の変数の値をコンソール出力します

* doubleの例

[source,java]
----
public class Main{
  // 略
}
----

みたく書いていましたが、これを html にすると、↓のように「doubleの例」の部分が吹き出しの一部として表示されてしまいます。

listUnderFukidashi.PNG

これを防ぐには、吹き出しとリストの間にコメントを挿入します。

test.adoc
<4> 2の変数の値をコンソール出力します

// こ↑こ↓

* doubleの例

[source,java]
----
public class Main{
  // 略
}
----

すると……

listUnderFukidashi2.PNG

無事に吹き出しとリストを別に出来ました。
Asciidoctor 文法クイックリファレンス(日本語訳)のリストのヒントを読んで思いつきました。

ただ、そもそもリストをセクション代わりに使うのが間違いでもある:sweat:

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?