aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor <pashev.igor@gmail.com>2010-11-13 18:31:58 +0300
committerIgor <pashev.igor@gmail.com>2010-11-13 18:31:58 +0300
commit66ef9d45417ab4d8c4e0ecbf519e2c751362f85d (patch)
tree687866d52ce2c6ce36741cab85b8fa01cd3d97f0
parentd3a5ea2be22e4c5e3e2b0262d1525bf53d54d48e (diff)
downloaddokuwiki-plugin-papers-66ef9d45417ab4d8c4e0ecbf519e2c751362f85d.tar.gz
Format author
-rw-r--r--bibtex.php43
1 files changed, 36 insertions, 7 deletions
diff --git a/bibtex.php b/bibtex.php
index 88904d4..a66b0c6 100644
--- a/bibtex.php
+++ b/bibtex.php
@@ -161,6 +161,7 @@ class BibtexParser
{
$text = preg_replace('/([^\\\\])~/u', '\\1&nbsp;', $text);
$text = preg_replace('/<<(.*?)>>/u', '«\1»', $text);
+ $text = preg_replace('/``(.*?)\'\'/u', '“\1”', $text);
$text = preg_replace('/(\d+)\s*-{1,3}\s*(\d+)/u', '\1&ndash;\2', $text);
$text = preg_replace('/---/u', '&mdash;', $text);
$text = preg_replace('/--/u', '&ndash;', $text);
@@ -348,7 +349,8 @@ class BibtexParserTeam extends BibtexParser
protected function format_editor()
{
$this->format_field_default('editor');
- $this->entry['editor'] = $this->_('Ed.&nbsp;by') . '&nbsp;' . $this->entry['editor'];
+ $this->entry['editor'] = $this->_('Ed.&nbsp;by')
+ . '&nbsp;' . $this->format_author1($this->entry['editor']);
}
protected function format_volume()
@@ -370,10 +372,37 @@ class BibtexParserTeam extends BibtexParser
$this->entry['number'] = $this->_('no.') . '&nbsp;' . $this->entry['number'];
}
+
+
+ /*
+ * И.Н. Пашев => Пашев И. Н.
+ * Игорь Пашев => Пашев И.
+ * Иг. Пашев => Пашев Иг.
+ * Пашев, Игорь Николаевич => Пашев И. Н.
+ * Пашев, И. Н. => Пашев И. Н.
+ */
protected function format_author1($author)
{
- $res = '';
- $res = $this->latex2html($author);
+ $res = ''; $aa = array();
+ $author = preg_replace('/\s*\.\s*/', '. ', $this->latex2html($author));
+
+ if ($i = mb_strpos($author, ','))
+ {
+ $main = mb_substr($author, 0, $i);
+ $aa = preg_split('/\s+/u', trim(mb_substr($author, $i+1)));
+ }
+ else
+ {
+ $aa = preg_split('/\s+/u', $author);
+ $main = array_pop($aa);
+ }
+
+ foreach ($aa as &$i)
+ $i = preg_replace('/^(.)[^.]*$/u', '$1.', $i);
+
+ array_unshift ($aa, $main);
+ $res = implode('&nbsp;', $aa);
+
return $res;
}
@@ -448,7 +477,7 @@ class BibtexParserTeam extends BibtexParser
protected function format_book()
{
- $parts = array(); // All parts are connected with '.&nbsp;&mdash; '
+ $parts = array(); // All parts are joined with '.&nbsp;&mdash; '
$part = '';
// FIXME : If $this->entry['count_authors'] > 3, place them after title?
@@ -507,7 +536,7 @@ class BibtexParserTeam extends BibtexParser
protected function format_article()
{
- $parts = array(); // All parts are connected with '.&nbsp;&mdash; '
+ $parts = array(); // All parts are joined with '.&nbsp;&mdash; '
$part = '';
// FIXME : If $this->entry['count_authors'] > 3, place them after title?
@@ -556,7 +585,7 @@ class BibtexParserTeam extends BibtexParser
protected function format_grant()
{
- $parts = array(); // All parts are connected with '.&nbsp;&mdash; '
+ $parts = array(); // All parts are joined with '.&nbsp;&mdash; '
if (!empty($this->entry['organization']))
@@ -595,7 +624,7 @@ class BibtexParserTeam extends BibtexParser
protected function format_inproceedings()
{
- $parts = array(); // All parts are connected with '.&nbsp;&mdash; '
+ $parts = array(); // All parts are joined with '.&nbsp;&mdash; '
$part = '';
if (!empty($this->entry['author']))