Nesting bullet lists and paragraphs in Asciidoctor
Asked Answered
S

3

7

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

Subterrane answered 20/2, 2018 at 16:51 Comment(2)
what would be if you add two asterisks?Drafty
The items a, b and c are not subitems of item 1 but are items of the first blabla paragraph. (Don't know if this answered your question)Subterrane
G
3

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.

Ge answered 3/3, 2018 at 0:21 Comment(1)
Your answer helped me to find my own, so I upvoted it :) Some notes: 1. Indentation in lists, in my experience, is quite oftenly breaks something, so I don't use it, 2. + at the end of lines translated to <br> tag, instead of new paragraph; so, each + should stand on it's own line.Fluker
F
6

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
Fluker answered 4/9, 2018 at 10:58 Comment(0)
G
3

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.

Ge answered 3/3, 2018 at 0:21 Comment(1)
Your answer helped me to find my own, so I upvoted it :) Some notes: 1. Indentation in lists, in my experience, is quite oftenly breaks something, so I don't use it, 2. + at the end of lines translated to <br> tag, instead of new paragraph; so, each + should stand on it's own line.Fluker
D
2

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

Drafty answered 20/2, 2018 at 16:58 Comment(3)
See my update at the end of my question. That what you suggest does not work when you start having paragraphs inside the bullets.Subterrane
Nice trick, making everything a bullet item. But how can I hide the bullet in front of the paragraphs? If this is possible then I have my answer.Subterrane
Labeled Lists can do the trick in part, but I could not make them to work in avoiding the bullet when adding a paragraph inside item a.1 inside paragraph 1 inside item aSubterrane

© 2022 - 2024 — McMap. All rights reserved.