aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-11-04 22:49:41 +0300
committerIgor <pashev.igor@gmail.com>2010-11-04 22:49:41 +0300
commitb672ba367d346b06eb09c63cc7c3b17b6db0f803 (patch)
treedfefd371147488a1eb42212f777c2a40d6aa7b79
parentd441520e4be3a7cf1e73c118c5b31bde670f7796 (diff)
downloaddokuwiki-plugin-papers-b672ba367d346b06eb09c63cc7c3b17b6db0f803.tar.gz
<grants> tag (just like <papers>, but with semantics in mind)
-rw-r--r--conf/default.php3
-rw-r--r--syntax.php13
2 files changed, 11 insertions, 5 deletions
diff --git a/conf/default.php b/conf/default.php
index f4357d5..6ae34fc 100644
--- a/conf/default.php
+++ b/conf/default.php
@@ -9,5 +9,6 @@ $conf['year_min'] = '2001';
$conf['papers_ns'] = 'papers';
$conf['filetypes'] = array('PDF', 'DjVu', 'PS', 'TIFF');
-$conf['bibtex'] = 'публикации'; // Wiki page with bibtex data
+$conf['papers'] = 'публикации'; // Wiki page with bibtex data
+$conf['grants'] = 'гранты';
diff --git a/syntax.php b/syntax.php
index 4f2b2ad..622887b 100644
--- a/syntax.php
+++ b/syntax.php
@@ -35,12 +35,14 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
{
$this->Lexer->addEntryPattern('<bibtex>(?=.*</bibtex>)', $mode, 'plugin_papers');
$this->Lexer->addEntryPattern('<papers>(?=.*</papers>)', $mode, 'plugin_papers');
+ $this->Lexer->addEntryPattern('<grants>(?=.*</grants>)', $mode, 'plugin_papers');
}
function postConnect()
{
$this->Lexer->addExitPattern('</bibtex>', 'plugin_papers');
$this->Lexer->addExitPattern('</papers>', 'plugin_papers');
+ $this->Lexer->addExitPattern('</grants>', 'plugin_papers');
}
function handle($match, $state, $pos, &$handler)
@@ -55,7 +57,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
return array($state, $tag, '', array());
case DOKU_LEXER_UNMATCHED :
- if ($tag === 'papers') // Parse <papers>...</papers>
+ if ($tag === 'papers' || $tag === 'grants')
{
$spec = array();
$fields = preg_split('/\s*\n\s*/u', $match);
@@ -63,9 +65,11 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
{
if (preg_match('/\s*(\w+?)\s*=\s*(.*)/u', $f, $m))
{
- $spec[$m[1]] = $m[2];
+ $spec[mb_strtolower($m[1])] = $m[2];
}
}
+
+ // begin: display options, not BiBTeX fields
$source = '';
if (isset($spec['source']))
{
@@ -74,7 +78,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
}
else
{
- $source = wikiFN($this->getConf('bibtex'));
+ $source = wikiFN($this->getConf($tag));
}
$options = array();
@@ -86,6 +90,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
unset($spec[$o]);
}
}
+ // end: display options, not BiBTeX fields
$bibtex = (!isset($options['byyear']) || $options['byyear']) ?
new BibtexParserTeam() : new BibtexParserWorker();
@@ -96,7 +101,7 @@ class syntax_plugin_papers extends DokuWiki_Syntax_Plugin
$bibtex->sort();
return array($state, $tag, $bibtex, $options);
}
- elseif ($tag === 'bibtex') // Parse <bibtex>...</bibtex>
+ elseif ($tag === 'bibtex')
{
$bibtex = new BibtexParserTeam();
$bibtex->read_text($match);