/**
  *
  */
 private function initializePatterns()
 {
     if (refnotes_configuration::getSetting('replace-footnotes')) {
         $entry = '(?:\\(\\(|\\[\\()';
         $exit = '(?:\\)\\)|\\)\\])';
         $id = '@@FNT\\d+|#\\d+';
     } else {
         $entry = '\\[\\(';
         $exit = '\\)\\]';
         $id = '#\\d+';
     }
     $strictName = refnotes_note::getNamePattern('strict');
     $extendedName = refnotes_note::getNamePattern('extended');
     $namespace = refnotes_namespace::getNamePattern('optional');
     $text = '.*?';
     $strictName = '(?:' . $id . '|' . $strictName . ')';
     $fullName = '\\s*(?:' . $namespace . $strictName . '|:' . $namespace . $extendedName . ')\\s*';
     $lookaheadExit = '(?=' . $exit . ')';
     $nameEntry = $fullName . $lookaheadExit;
     $extendedName = '(?:' . $id . '|' . $extendedName . ')';
     $optionalFullName = $namespace . $extendedName . '?';
     $structuredEntry = '\\s*' . $optionalFullName . '\\s*>>' . $text . $lookaheadExit;
     $define = '\\s*' . $optionalFullName . '\\s*>\\s*';
     $optionalDefine = '(?:' . $define . ')?';
     $lookaheadExit = '(?=' . $text . $exit . ')';
     $defineEntry = $optionalDefine . $lookaheadExit;
     $this->entryPattern = $entry . '(?:' . $nameEntry . '|' . $structuredEntry . '|' . $defineEntry . ')';
     $this->exitPattern = $exit;
     $this->handlePattern = '/' . $entry . '\\s*(' . $optionalFullName . ')\\s*(?:>>(.*))?(.*)/s';
 }
Example #2
0
 /**
  *
  */
 public static function getNamePattern($type)
 {
     if ($type == 'full-extended' || $type == 'extended') {
         $result = $type == 'full-extended' ? refnotes_namespace::getNamePattern('optional') : '';
         $result .= '[[:alpha:]][\\w.&\\(\\)\\[\\]{}+-]*';
     } else {
         $result = '[[:alpha:]]\\w*';
     }
     return $result;
 }
Example #3
0
 /**
  *
  */
 private function parseAttributes($syntax)
 {
     $propertyMatch = array('ns' => '/^' . refnotes_namespace::getNamePattern('required') . '$/', 'limit' => '/^\\/?\\d+$/');
     $attribute = array();
     $token = preg_split('/\\s+/', $syntax, -1, PREG_SPLIT_NO_EMPTY);
     foreach ($token as $t) {
         foreach ($propertyMatch as $name => $pattern) {
             if (preg_match($pattern, $t) == 1) {
                 $attribute[$name][] = $t;
                 break;
             }
         }
     }
     if (array_key_exists('ns', $attribute)) {
         /* Ensure that namespaces are in canonic form */
         $attribute['ns'] = array_map('refnotes_namespace::canonizeName', $attribute['ns']);
         if (count($attribute['ns']) > 1) {
             $attribute['map'] = array_slice($attribute['ns'], 1);
         }
         $attribute['ns'] = $attribute['ns'][0];
     } else {
         $attribute['ns'] = ':';
     }
     if (array_key_exists('limit', $attribute)) {
         $attribute['limit'] = end($attribute['limit']);
     }
     return $attribute;
 }