Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nesting bullet lists and paragraphs in Asciidoctor

How should I write the Asciidoc(tor) to have the following output:

* item 1
  * item a
    paragraph 1 inside item a
      * item a.1 inside paragraph 1 inside item a
        paragraph a.1 inside item a.1
      * item a.2 inside paragraph 1 inside item a
        paragraph a.2 inside item a.1
    paragraph 2 inside item a
  * item b
    paragraph 1 inside item b
* item 2

UPDATE: @TigerTV.ru suggested a nice trick, but it requires the capability to hide the bullets in bullet lists. How can this be done?

Thanks

like image 345
mljrg Avatar asked Feb 20 '18 16:02

mljrg


People also ask

How do I add bullet points in AsciiDoc?

You can make unordered lists in AsciiDoc by starting the lines with a designated marker. An unordered list is a list with items that are prefixed with symbol, such as a bullet. AsciiDoc builds on the well-established convention of using an asterisk or hyphen to identify a list item.

What are nested bullet points?

Nesting lists A nested list – a list within a list – is a numbered or bulleted list with subordinate (usually indented) numbered or bulleted lists.

How do I add nested bullets?

To do this, simply press 'shift + enter' on your keyboard when your cursor is at the end of a list item, and the next list item will be indented. There won't be any bullet (or number), on the indented line, so I recommend you add a dash '-' character, followed by a space and then your content.


3 Answers

https://asciidoctor.org/docs/user-manual/#attaching-to-an-ancestor-list:

You may find that you need to attach block content to a parent list item instead of the current one. In other words, you want to attach the block content to the parent list item so it becomes a sibling of the child list. To do this, you add a blank line before the list continuation.

* parent list item
** child list item

+
paragraph attached to parent list item

More complex example:

* Foo
** Aaa
** Bbb

+
Continuation of Foo
* Bar
+
Continuation of Bar
* Baz
+
Continuation of Baz

** Ccc
** Ddd
* Xyz

Notes:

  • You need blank line after Bbb. This is by design:

    The blank line signals to the list continuation to move out of the current list so it attaches the block to the last item of the parent list.

  • You also need blank line before Ccc. This is currently an open issue #2509.

A block attached to the grandparent list item:

* grandparent list item
** parent list item
*** child list item


+
paragraph attached to grandparent list item

Using blank lines to back out of the nesting may feel fragile. A more robust way to accomplish the same thing is to enclose the nested lists in an open block. That way, it’s clear where the nested list ends and the enclosing list continues:

* grandparent list item
+
--
** parent list item
*** child list item
--
+
paragraph attached to grandparent list item
like image 193
john c. j. Avatar answered Sep 22 '22 11:09

john c. j.


Think this will work:

* item 1
 ** item a +
    paragraph 1 inside item a
+
--
*** item a.1 inside paragraph 1 inside item a +
    paragraph a.1 inside item a.1
*** item a.2 inside paragraph 1 inside item a +
    paragraph a.2 inside item a.1
--
+
paragraph 2 inside item a
 ** item b +
    paragraph 1 inside item b
* item 2

Tested with Asciidoctor 1.5.6.1.

like image 22
rimkojr Avatar answered Sep 19 '22 11:09

rimkojr


You can use several asterisks for levels:

* item 1
** item a
*** paragraph 1 inside item a
**** item a.1 inside paragraph 1 inside item a
**** item a.2 inside paragraph 1 inside item a
*** paragraph 2 inside item a
** item b
*** paragraph 1 inside item b
* item 2

https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/#lists

like image 45
TigerTV.ru Avatar answered Sep 23 '22 11:09

TigerTV.ru