Go to the FreeLists Home Page Home Signup Help Login
 



[dokuwiki] || [Date Prev] [06-2007 Date Index] [Date Next] || [Thread Prev] [06-2007 Thread Index] [Thread Next]

[dokuwiki] Re: List syntax

  • From: Adrian Sai-wah Tam <adrian@xxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Mon, 11 Jun 2007 14:00:30 +0800
Thanks Ferdinard, I follow your pointer and coded the attached plugin (supposed to be put on lib/plugins/mllist/syntax.php), which makes all the lines following a bullet with 3 or more leading spaces concatenated.

Everyone please enjoy.

Regards,
Adrian.

Ferdinand Soethe wrote:
I find Adrians proposal (make the parser understand that indented lines
immediately following a list item) are additional lines for that list
item) quite useful.

It certainly would be more intuitive as we write lists in emails like
that everyday.

Problem would be to associate the amount of indent with a list item if
there is more than one layer of list items such as:

* dsfdsf
  * sdfdsfasf
    sjdklsdkjfkjdskf

Perhaps you could write this as a plugin?
The code for the creole-plugin might be a good starting point to figure
out how to intercept normal parsing.

Best regards,
Ferdinand Soethe

Adrian Sai-wah Tam wrote:
Hi,

Sometimes, we may wrote in a list form, such as:
=========
 * This is an item
 * This is another item with
    a long line broken into two
 * This is the third item
=========
When we look at the source, we (human) obviously know the second and
third line is a single item. However, the parser don't. I would like to
change that (at least for my incarnation), does anyone know where to do?
I looked at inc/parser/xhtml.php but got no clue to do.

- Adrian.


*/ // must be run within Dokuwiki if(!defined('DOKU_INC')) die(); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_mllist extends DokuWiki_Syntax_Plugin { function getInfo(){ return array( 'author' => 'Adrian Sai-wah Tam', 'email' => 'adrian.sw.tam@xxxxxxxxx', 'date' => '2007-06-06', 'name' => 'Multiline list plugin', 'desc' => 'Allows a list item to break into multiple lines with indentation on non-bullet lines', 'url' => 'http://aipl.ie.cuhk.edu.hk/~adrian/doku.php/software/mllist' ); } function getType(){ return 'container'; } function getPType(){ return 'block'; } function getSort(){ return 9; } function getAllowedTypes(){ return array('formatting', 'substition', 'disabled', 'protected'); } function connectTo($mode){ $this->Lexer->addEntryPattern('\n[ \t]*[\-\*](?!\*)', $mode, 'plugin_mllist'); $this->Lexer->addPattern('\n[ \t]*[\-\*]+', 'plugin_mllist'); $this->Lexer->addPattern('\n[ \t]{2,}(?=\s)', 'plugin_mllist'); // Continuation lines need at least three spaces for indentation } function postConnect(){ $this->Lexer->addExitPattern('\n','plugin_mllist'); } function handle($match, $state, $pos, &$handler){ switch ($state){ case DOKU_LEXER_ENTER: $ReWriter = & new Doku_Handler_List($handler->CallWriter); $handler->CallWriter = & $ReWriter; $handler->_addCall('list_open', array($match), $pos); break; case DOKU_LEXER_EXIT: $handler->_addCall('list_close', array(), $pos); $handler->CallWriter->process(); $ReWriter = & $handler->CallWriter; $handler->CallWriter = & $ReWriter->CallWriter; break; case DOKU_LEXER_MATCHED: if (preg_match("/^\s+$/",$match)) break; // Captures the continuation case $handler->_addCall('list_item', array($match), $pos); break; case DOKU_LEXER_UNMATCHED: $handler->_addCall('cdata', array($match), $pos); break; } return true; } function render($mode, &$renderer, $data){ return true; } } //Setup VIM: ex: et ts=4 enc=utf-8 :




[ Home | Signup | Help | Login | Archives | Lists ]

All trademarks and copyrights within the FreeLists archives are owned by their respective owners.
Everything else ©2007 Avenir Technologies, LLC.