Include List Item Content
You can use the include directive to include the content of a list item from another file, but there are some things you need to be aware of.
Recall that the include
directive must be defined on a line by itself.
This presents a challenge with lists since each list item must begin with the list marker.
We can solve this by using the built-in empty
attribute to initiate the list item, then follow that line with the include directive to bring in the actual content.
Here’s an example of how to use the empty
attribute and the include directive to define a list item, then include the primary text from another file:
* {empty}
include::item-text.adoc[]
This technique works well if you control the contents of the included file and can ensure it only contains adjacent lines of text. If a list item does not contain adjacent lines, the list may be terminated. So we need a bit more syntax.
If you can’t guarantee that all the included lines will be adjacent, you’ll want to tuck the include directive inside an open block.
This keeps all the include lines together, enclosed inside the boundaries of the block.
You then attach this block to the list item using a list continuation (i.e., +
).
Here’s an example of how to include complex content from another file into a list item:
* {empty}
+
--
include::complex-list-item.adoc[]
--
See dropping the principal text of a list item for another example of this technique.