diff options
author | andi <andi@splitbrain.org> | 2005-05-21 23:04:30 +0200 |
---|---|---|
committer | andi <andi@splitbrain.org> | 2005-05-21 23:04:30 +0200 |
commit | 107b01d60353b74aebd1901b6f19e70a998b2594 (patch) | |
tree | 5584f0b9c2eedf2050e01aac79ffe81cf6021da2 /inc/plugins/info/syntax.php | |
parent | 5233912627d370d8a346a810cc95c46554a4a8e1 (diff) | |
download | rpg-107b01d60353b74aebd1901b6f19e70a998b2594.tar.gz rpg-107b01d60353b74aebd1901b6f19e70a998b2594.tar.bz2 |
sorting support for syntax plugins, info plugin now actually does something
Syntax plugins now need to implement getSort() which should return a number.
This number is used to add all syntax modes in the correct order. To see a
list in which order current modes are loaded you can use the info plugin like
this:
~~INFO:syntaxmodes~~ lists all known modes (includes existing plugins) with
their sorting score
~~INFO:syntaxtypes~~ lists all syntax types and their registered modes (useful
for implementing the getType() function.
darcs-hash:20050521210430-9977f-2baaf6043afc6ea3fed41cdca97564218fb519c2.gz
Diffstat (limited to 'inc/plugins/info/syntax.php')
-rw-r--r-- | inc/plugins/info/syntax.php | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/inc/plugins/info/syntax.php b/inc/plugins/info/syntax.php index 4567de685..bf45e5d11 100644 --- a/inc/plugins/info/syntax.php +++ b/inc/plugins/info/syntax.php @@ -22,7 +22,14 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { function getType(){ return 'substition'; } - + + /** + * Where to sort in? + */ + function getSort(){ + return 155; + } + /** * Connect pattern to lexer @@ -47,8 +54,14 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { if($mode == 'xhtml'){ //handle various info stuff switch ($data[0]){ - case 'foo': - $renderer->doc .= "foo is foo"; + case 'version'; + $renderer->doc .= getVersion(); + break; + case 'syntaxmodes'; + $renderer->doc .= $this->_syntaxmodes_xhtml(); + break; + case 'syntaxtypes'; + $renderer->doc .= $this->_syntaxtypes_xhtml(); break; default: $renderer->doc .= "no info about ".htmlspecialchars($data[0]); @@ -58,6 +71,40 @@ class syntax_plugin_info extends DokuWiki_Syntax_Plugin { return false; } + /** + * lists all known syntax types and their registered modes + */ + function _syntaxtypes_xhtml(){ + global $PARSER_MODES; + $doc = ''; + + $doc .= '<table class="inline"><tbody>'; + foreach($PARSER_MODES as $mode => $modes){ + $doc .= '<tr>'; + $doc .= '<td class="leftalign">'; + $doc .= $mode; + $doc .= '</td>'; + $doc .= '<td class="leftalign">'; + $doc .= join(', ',$modes); + $doc .= '</td>'; + $doc .= '</tr>'; + } + $doc .= '</tbody></table>'; + return $doc; + } + + /** + * lists all known syntax modes and their sorting value + */ + function _syntaxmodes_xhtml(){ + $modes = p_get_parsermodes(); + $doc = ''; + + foreach ($modes as $mode){ + $doc .= $mode['mode'].' ('.$mode['sort'].'), '; + } + return $doc; + } } //Setup VIM: ex: et ts=4 enc=utf-8 : |