DokuWiki

It's better when it's simple

User Tools

Site Tools


faq:lists

Working with Lists

Multiline List Items

:?: How can I add a code block or multiple lines in a list item?

:!: The list syntax expects you to put each item in a single line and you may not interrupt numbered lists or the index will restart at 1. This makes it impossible to add tables into a list item for example. However you can add code/file block or line breaks in a list item. For code blocks make sure they start on the same line as your item, for linebreaks use the forced line break syntax \\.

Here's an example:

  - first item 
  - second item with linebreak\\ second line
  - third item with code: <code>
some code
comes here
</code>
  - fourth item

Which renders like this:

  1. first item
  2. second item with linebreak
    second line
  3. third item with code:
    some code
    comes here
  4. fourth item

You can use the same trick to include other syntax like tables into a list by using the wrap plugin to wrap your table.

To add a blank line between number list items do this:

  - Ordered List Item1 \\ \\           //(line break, linebreak, space)
  - Ordered List Item2
  - Ordered List Item3 

Which results in this:

  1. Ordered List Item1

  2. Ordered List Item2
  3. Ordered List Item3

For visual clarity you may prefer to add a non-breaking space after the line breaks e.g.

\\ \\~~

where '~~' is defined in as a non-breaking space in conf/entities.conf

Continue List Numbering

:?: Is it possible to have two ordered lists, with the second picking up numbering at where the first stopped?

:!: No, that's currently not possible with the default list syntax. As soon as one list finishes, the numbering restarts:

  - first item
  - second item

No longer a list

  - third item? no, it's the first item of the second list
  1. first item
  2. second item

No longer a list

  1. third item? no, it's the first item of the second list

Styling the List Numbering of ordered lists

:?: I don't like the default list numbering of ordered lists. How can I change it?

:!: The number format is defined through CSS. The default template defines formatting for the first 4 list levels of ordered lists:

div.dokuwiki ol { list-style-type: decimal; }
div.dokuwiki ol ol { list-style-type: upper-roman; }
div.dokuwiki ol ol ol { list-style-type: lower-alpha; }
div.dokuwiki ol ol ol ol { list-style-type: lower-greek; }

You can see all allowed property values for list-style-type in a CSS reference such as MDN.

Styling the List Numbering of unordered lists

:!: The bullet format for unordered lists is also defined through CSS. The default looks like this:

div.dokuwiki ul {
  line-height: 1.5em;
  list-style-type: square;
  list-style-image: none;
  margin: 0 0 1em 3.5em;
  color: __text_alt__;
}

and you could replace it e.g. with this:

div.dokuwiki ul { list-style-type: disc; }
div.dokuwiki ul ul { list-style-type: circle; }
div.dokuwiki ul ul ul { list-style-type: square; }
div.dokuwiki ul ul ul ul { list-style-type: square; }

sadly you are only able to choose between the symbols circle, disc and square. If you'd like a different unicode symbol (e.g. from Unicodeblock Dingbats) without utilizing picture try:

div.dokuwiki ul .li:before {content: '➤';}
div.dokuwiki ul ul .li:before {content: '♫';}
div.dokuwiki ul ul ul .li:before {content: '☛';}
div.dokuwiki ul ul ul ul .li:before {content: '⤷';}
div.dokuwiki ul ul ul ul ul .li:before {content: '✩';}

You can easily override this in your userstyle.css.

List Plugins

There are several plugins that implement alternative syntax for lists, including definition lists, and might make things possible that can't be achieved by the default syntax. See Plugins tagged with "list".

faq/lists.txt · Last modified: 2023-07-10 07:18 by saggi

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki