Инструменты пользователя

Инструменты сайта


wiki:plugin:parserarray

Это старая версия документа!


CamelCase для «ДокуВики»

Экспортирует массив инструкций парсера для текущей страницы.

Этот плагин был разработан Håkan Sandell.

This export plugin is a development tool and only useful for understanding the DokuWiki parser.

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Usage

This plugin exports/shows the parser instruction array for the current page. Useful for anyone interested in understanding how the DokuWiki parser works and is reading parser.

Use do=export_parserarray to display the parser array.

downloadurl: https://github.com/HakanS/dokuwiki-plugin-parserarray/zipball/master bugtracker : https://github.com/HakanS/dokuwiki-plugin-parserarray/issues sourcerepo : https://github.com/HakanS/dokuwiki-plugin-parserarray/

Совместимость

  • 2005-09-19+

:!: Внимание: Это расширение не обновлялось более 2 лет. Возможно, оно больше не поддерживается и может иметь проблемы с совместимостью.

Монтаж

Используйте менеджер плагинов для установки или…

  1. скачать zip-файл
  2. распаковать его в <dokuwiki>/lib/plugins/
  3. войдите как администратор и измените плагин в менеджере конфигурации

Примеры/Использование

Этот плагин заменяет текущие обработчики DokuWiki для разметки CamelCase. Он создаст ссылку на страницу с подчеркиваниями между словами CamelCase.

например

index.php
CamelCase => camel_case

Стандартное поведение DokuWiki заключается в создании ссылки на страницу с CamelCase, преобразованным в нижний регистр (например, camelcase). Это может привести к снижению читаемости названий страниц. Альтернативой является установка параметра конфигурации useheading в вашем conf/local.php файле.

Синтаксис

Подробности

PHP-источник

lib/plugins/camelcase/syntax.php

<?php
/**
 * CamelCase Plugin: replaces DokuWiki's own code syntax
 * 
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Christopher Smith <chris@jalakai.co.uk>  
 */
 
if(!defined('DOKU_INC')) die();
 
/**
 * All DokuWiki plugins to extend the parser/rendering mechanism
 * need to inherit from this class
 */
class  syntax_plugin_camelcase extends DokuWiki_Syntax_Plugin {
 
 
    /**
     * return some info
     */
    function getInfo(){
      return array(
        'author' => 'Christopher Smith',
        'email'  => 'chris@jalakai.co.uk',
        'date'   => '2008-08-13',
        'name'   => 'Camel Case',
        'desc'   => 'Override default DokuWiki CamelCase syntax',
        'url'    => 'http://www.dokuwiki.org/plugin:camelcase',
      );
    }
 
    /**
     * Syntax Type
     *
     * Needs to return one of the mode types defined in $PARSER_MODES in parser.php
     */
    function getType(){
        return('substition');
    }
 
    function connectTo($mode) {
        $this->Lexer->addSpecialPattern(
                '\b[A-Z]+[a-z]+[A-Z][A-Za-z]*\b',$mode,'plugin_camelcase'
            );
    }
 
    function getSort() {
        return 275;   // needs to be lower than 290
    }
 
    /**
     * Handler to prepare matched data for the rendering process
     */
    function handle($match, $state, $pos, Doku_Handler $handler){
 
        preg_match_all('/[A-Z][^A-Z]*/u',$match, $matches);
        $link = implode('_',$matches[0]);
        return array($link, $match);
    }
 
    /**
     * Handles the actual output creation.
     */
    function render($format, Doku_Renderer $renderer, $data) {
      $renderer->internallink($data[0],$data[1]); 
    }
 
}
//Setup VIM: ex: et ts=4 enc=utf-8 :

Файл для загрузки

Лицензия

Это не обязательно, но, пожалуйста, рассмотрите возможность ссылки на эту страницу с вашего сайта, если вам нравится этот продукт.

Только авторизованные участники могут оставлять комментарии.
wiki/plugin/parserarray.1737113942.txt.gz · Последнее изменение: 2025/01/17 14:39 — vladpolskiy