Not logged in. · Lost password · Register
Forum: General Help and Support Syntax and Usage RSS
delimiter for acronym file
Avatar
mekineer #1
Member since Mar 2018 · 28 posts
Group memberships: Members
Show profile · Link to this post
Subject: delimiter for acronym file
Continuation of thread: https://forum.dokuwiki.org/thread/12967
Since some people are touchy about continuing an old thread.

Maybe there is a way to change the delimiter in acronyms.conf from a whitespace to something else, like 4 whitespaces.

Can someone who can read PHP see if the delimiter is in parser.php in this section:

class Doku_Parser_Mode_acronym extends Doku_Parser_Mode {
    // A list
    var $acronyms = array();
    var $pattern = '';

    function __construct($acronyms) {
        usort($acronyms,array($this,'_compare'));
        $this->acronyms = $acronyms;
    }

    function preConnect() {
        if(!count($this->acronyms)) return;

        $bound = '[\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]';
        $acronyms = array_map('Doku_Lexer_Escape',$this->acronyms);
        $this->pattern = '(?<=^|'.$bound.')(?:'.join('|',$acronyms).')(?='.$bound.')';
    }

    function connectTo($mode) {
        if(!count($this->acronyms)) return;

        if ( strlen($this->pattern) > 0 ) {
            $this->Lexer->addSpecialPattern($this->pattern,$mode,'acronym');
        }
    }

    function getSort() {
        return 240;
    }

    /**
     * sort callback to order by string length descending
     */
    function _compare($a,$b) {
        $a_len = strlen($a);
        $b_len = strlen($b);
        if ($a_len > $b_len) {
            return -1;
        } else if ($a_len < $b_len) {
            return 1;
        }

        return 0;
    }
}

Or maybe this section of xhtml.php:

    function acronym($acronym) {

        if(array_key_exists($acronym, $this->acronyms)) {

            $title = $this->_xmlEntities($this->acronyms[$acronym]);

            $this->doc .= '<abbr title="'.$title
                .'">'.$this->_xmlEntities($acronym).'</abbr>';

        } else {
            $this->doc .= $this->_xmlEntities($acronym);
        }
    }
Avatar
mekineer #2
Member since Mar 2018 · 28 posts
Group memberships: Members
Show profile · Link to this post
I prefer the internal acronym function over the Explain plugin, for the following reasons:

I like the acronym style of the underlining.
I like the acronym style of tooltip.
I don't want an internal or external link.
I don't want the tooltip plugin, because I want the definition to be wiki-wide.

Basically, I want to change the acronym file delimiter from a whitespace to 4 whitespaces.  That is all.

So help me God, I'll use underscores for multi-word terms if I have to.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-10-14, 21:07:00 (UTC +02:00)