Asciidoctor: Placing Images Within Lists

A nice little feature that isn’t made quite clear in Asciidoctor’s nice and comprehensive user manual is the ability to place images in the middle of lists.

Lists

Asciidoctor lists can be either ordered or unordered and are created like so:

//Some markup

.An ordered list
. Item 1
. Item 2
. Item 3

//Other markup

And

//Some markup

.An unordered list
* Item 1
* Item 2
* Item 3

//Other markup

Images

Asciidoctor images can be added using the macro:

image::logo.png[]

Why Not Both?

Trying to combine the two, my intuition told me I should try something like

.An ordered list
. Item 1 image::logo.png[]
. Item 2
. Item 3

But this just results in image macro text being part of the first item.
Perhaps something like this?

.An ordered list
. Item 1
image::logo.png[]
. Item 2
. Item 3

But this ends up breaking the list into two.

Apparently the solution to this is a simple new line containing a single + symbol:

.An ordered list
. Item 1
+
image::logo.png[]
. Item 2
. Item 3
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s