DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:yalist

yalist Plugin

Compatible with DokuWiki

  • 2024-02-06 "Kaos" unknown
  • 2023-04-04 "Jack Jackrum" yes
  • 2022-07-31 "Igor" unknown
  • 2020-07-29 "Hogfather" yes

plugin Simple universal list plugin

Last updated on
2023-06-30
Provides
Syntax
Repository
Source
Conflicts with
ckgedit, indexmenu2, navi

Overview

There are many list syntax plugins (see the list of similar plugins above), but this one is mine. I created it because I am not happy with any of the others:

  • Only lists and deflist allow paragraph breaks within list items, but their syntax is radically different from the standard DokuWiki syntax for lists. Worse, the syntax that each plugin introduces for list item terminators differs from the other.1)
  • definitions and definitionlist do not allow nested definition lists.
  • deflist and dl allow nested definition lists, and un/ordered lists nested in definition lists,2) but neither one properly uses the “class=levelN” style to mark the depth of a list item, as the standard DokuWiki list handler does.
  • deflist and dl automatically create a “bookmark” for each definition list term, which introduces a new requirement that definition list terms be unique within a document. This is IMO not a good idea.

My goal in creating yalist was to integrate definition lists into the existing nestable list handler, and to allow list items to contain multiple paragraphs, while maintaining syntax- and output-level compatibility with the existing list handler. yalist achieves this by preempting DokuWiki's list handler, replacing it with a new handler and renderer that render the standard list syntax exactly as DokuWiki would.

Install

Search and install ​the plugin using the Extension ​Manager.

Syntax

  - ordered list item            [<ol><li>]  <!-- as standard syntax -->
  * unordered list item          [<ul><li>]  <!-- as standard syntax -->
  ? definition list term         [<dl><dt>]
  : definition list definition   [<dl><dd>]

  -- ordered list item w/ multiple paragraphs
  ** unordered list item w/ multiple paragraphs
  :: definition list definition w/multiple paragraphs
  .. new paragraph in --, **, or ::

Lists can be nested within lists by indenting them further, just as in the standard DokuWiki syntax.

Example

The following DokuWiki source:

  - Ordered list item 1
  - Ordered list item 2
  -- Ordered list item 3...
  .. ... in multiple paragraphs
  - Ordered list item 4

  * Unordered list item
  ** Unordered list item...
  .. ... in multiple paragraphs

  - Ordered list, first level
    - Second level
      - Third level
        - Fourth level
    -- Back to second level
      - //Second?! What happened to third?//
    .. //Quiet, you.//
  - Back to first level
  - Still at first level

  ? Definition list
  : Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content. [Source: W3C]
  ? Definition list w/ multiple paragraphs
  :: The style sheet provided with this plugin will render these paragraphs...
  .. ... to the left of the term being defined.
    ? Definition list w/ multiple "paragraphs"
    : Another way to separate blocks of text in a definition...
    : ... is to simply have multiple definitions for a term (or group of terms).

  : This definition list has DD tags without any preceding DT tags.
  : Hey, it's legal XHTML.
  ? Just like DT tags without following DD tags.
  ?? But DT tags can't contain paragraphs. That would __not__ be legal XHTML.
  .. If you try, the result will be rendered oddly.

… is rendered in XHTML as follows:

<ol>
<li class="level1"><div class="li">
 Ordered list item 1
</div></li>
<li class="level1"><div class="li">
 Ordered list item 2
</div></li>
<li class="level1"><div class="li">
<p>
 Ordered list item 3&hellip;
</p><p>
 &hellip; in multiple paragraphs
</p>
</div></li>
<li class="level1"><div class="li">
 Ordered list item 4
</div></li>
</ol>
 
<ul>
<li class="level1"><div class="li">
 Unordered list item
</div></li>
<li class="level1"><div class="li">
<p>
 Unordered list item&hellip;
</p><p>
 &hellip; in multiple paragraphs
</p>
</div></li>
</ul>
 
<ol>
<li class="level1"><div class="li">
 Ordered list, first level
</div><ol>
<li class="level2"><div class="li">
 Second level
</div><ol>
<li class="level3"><div class="li">
 Third level
</div><ol>
<li class="level4"><div class="li">
 Fourth level
</div></li>
</ol>
</li>
</ol>
</li>
<li class="level2"><div class="li">
<p>
 Back to second level
</p>
</div><ol>
<li class="level3"><div class="li">
 <em>Second?! What happened to third?</em>
</div></li>
</ol>
<div class="li">
<p>
 <em>Quiet, you.</em>
</p>
</div></li>
</ol>
</li>
<li class="level1"><div class="li">
 Back to first level
</div></li>
<li class="level1"><div class="li">
 Still at first level
</div></li>
</ol>
 
<dl>
<dt class="level1"><span class="dt"> Definition list</span></dt>
<dd class="level1"> Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content. [Source: <acronym title="World Wide Web Consortium">W3C</acronym>]</dd>
<dt class="level1"><span class="dt"> Definition list w/ multiple paragraphs</span></dt>
<dd class="level1"><p>
 The style sheet provided with this plugin will render these paragraphs&hellip;
</p><p>
 &hellip; to the left of the term being defined.
</p><dl>
<dt class="level2"><span class="dt"> Definition list w/ multiple “paragraphs”</span></dt>
<dd class="level2"> Another way to separate blocks of text in a definition&hellip;</dd>
<dd class="level2"> &hellip; is to simply have multiple definitions for a term (or group of terms).</dd>
</dl>
</dd>
</dl>
 
<dl>
<dd class="level1"> This definition list has DD tags without any preceding DT tags.</dd>
<dd class="level1"> Hey, it&#039;s legal <acronym title="Extensible HyperText Markup Language">XHTML</acronym>.</dd>
<dt class="level1"><span class="dt"> Just like DT tags without following DD tags.</span></dt>
<dt class="level1"><span class="dt">? But DT tags can&#039;t contain paragraphs. That would <em class="u">not</em> be legal <acronym title="Extensible HyperText Markup Language">XHTML</acronym>.
  .. If you try, the result will be rendered oddly.</span></dt>
</dl>

Executed as sample here.

Discussion

Updated with bugfixes and enhancements. In the unlikely event that anyone downloaded this plugin already, try it again now. — Ben Slusky 2007-11-10 02:30

FIXME Great idea but seems to be buggy. Once I installed the plugin all bullets are treated as new lists. Basically if I have

  * Item 1
  * Item 2
  * Item 3

The plugin will interpret them as if I wrote

  * Item 1
    * Item 2
      * Item 3

Worse than that, it seems to break all \[\[ \]\] interwiki links

Bulleted lists and interwiki links both work for me… do you have a public site I can look at? — Ben Slusky 2007-11-24 23:39

FIXME Ben, this seems to be almost exactly the right solution, but there's one thing it doesn't do correctly. I want to write

  * First level
  ** First level
    * Second level
    * Second level
  .. continuing the last first level point

but this doesn't work: the .. isn't interpreted, and just becomes part of the last second-level bullet. It seems that the continuation context of the first level is lost in the transition to the second level. I can continue a second level bullet, but to go back to the first level I have to start a new bullet.

Any chance of this being corrected any time soon? Thanks, Andrew.

Maybe the ClearFloat Outdent plugin can do some good for this thingy you describe… It's just an idea LOL so please don't hang me on it. HTH
Mischa The Evil 2008/06/11 18:38
Fixed in the latest version. — Ben Slusky 2008-07-08 02:02
Works—thanks! Andrew

FIXME I also wanted to be able to use markup provided by DokuWiki Core (DWC) and some DokuWiki Plugins (DWP's) of the mode type container3) but that wasn't possible due to the fact that yalist doesn't allow markup provided by DWC and DWP's which are of the mode type container.

This can be changed easily by adding the container-mode type as a new (additional) argument of the method getAllowedTypes(), which itself returns an array of mode types that may be nested within yalist's own markup.
This change can be applied by modifying line 56 from

        return array('substition', 'protected', 'disabled', 'formatting');

to

        return array('container', 'substition', 'protected', 'disabled', 'formatting');

I haven't noticed any unwanted behaviour afterwards, but YMMV ;-)

Mischa The Evil 2008/06/11 22:54

Hm… I think this would result in invalid XHTML, so it's not going in. Sorry. — Ben Slusky 2008-07-08 02:14
A possible work-arround might to put such in what ever division (at least it works for tables in this case:
  ? text
  :: <div table>
|text|text|
|text|text|</div>

"Samana Johann" 2019-09-04 06:05

Updated on 8 July 2008 to add support for LaTeX output (thanks to Michael Strey) and fix a formatting error when “..” is shallower than the preceding list markup. — Ben Slusky 2008-07-28 02:25


Where would I modify the code to allow the plugin to interpret “#” as an ordered list (ideally in addition to “-”, but instead of will do too)? — Ashtagon 2011-Aug-8.


Feature Request

I need very often line breaks (<br>) but not paragraph breaks (<p>), especially when inserting images inside lists. My current workaround is using \\ but it's not very readyble because of huge lines. Would it be somehow possible to have a line break syntax like e.g. . at the beginning of the line?

1)
Which is especially strange, since they were written by the same author.
2)
lists and deflist in combination allow arbitrary nesting of lists.
plugin/yalist.txt · Last modified: 2023-10-31 00:06 by Klap-in

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