ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/website/www.git/commit/?id=be6cc2017ab8f34378f8c36f70e08335c87309d5

commit be6cc2017ab8f34378f8c36f70e08335c87309d5
Author: Andy Williams <a...@andywilliams.me>
Date:   Mon Oct 30 16:16:54 2017 +0000

    codelink: Actually render with a massive list of symbols
    
    Also look up the language list dynamically :)
---
 public_html/lib/plugins/codelink/syntax.php | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/public_html/lib/plugins/codelink/syntax.php 
b/public_html/lib/plugins/codelink/syntax.php
index 8505b0fb..476f01e4 100644
--- a/public_html/lib/plugins/codelink/syntax.php
+++ b/public_html/lib/plugins/codelink/syntax.php
@@ -32,10 +32,6 @@ class syntax_plugin_codelink extends DokuWiki_Syntax_Plugin {
                 $keys_array = file($extn_list, FILE_IGNORE_NEW_LINES | 
FILE_SKIP_EMPTY_LINES);
                 $this->keydata[$language]['link'] = $link_array[0];
                 $this->keydata[$language]['keys'] = $keys_array;
-                foreach ($keys_array as $k) {
-                    $this->Lexer->addSpecialPattern($k . '()', 'base', 
'plugin_codelink');
-                    $this->Lexer->addSpecialPattern($k, 'base', 
'plugin_codelink');
-                }
             }
         }
     }
@@ -64,13 +60,19 @@ class syntax_plugin_codelink extends DokuWiki_Syntax_Plugin 
{
      * @param string $mode Parser mode
      */
     public function connectTo($mode) {
-        // FIXME: make this cleaner
-        // languages supported here (languages supported list)
-        $langs = array('c');
-        foreach($langs as $l) {
+        global $conf;
+        $langs = opendir($conf['datadir'] . '/' . $conf['code_extn']);
+        while (false !== ($l = readdir($langs))) {
+            if ($l == "." || $l == "..") {
+                continue;
+            }
+
             $this->Lexer->addSpecialPattern('~~CODE-' . $l . '~~', $mode, 
'plugin_codelink');
             $this->load_lang_data($l);
         }
+
+        $this->Lexer->addSpecialPattern('[\w-]+\(?\)?', $mode, 
'plugin_codelink');
+        closedir($langs);
     }
 
     /**
@@ -96,6 +98,11 @@ class syntax_plugin_codelink extends DokuWiki_Syntax_Plugin {
             $this->keylanguage = $language;
         } else {
             $symbol = str_replace("()", "", $match);
+            if (!in_array($symbol, 
$this->keydata[$this->keylanguage]['keys'])) {
+                $data[0] = $match;
+                return $data;
+            }
+
             $data[0] = '<code class="code"><a href=' .
               str_replace
               (

-- 


Reply via email to