diff options
author | Igor <pashev.igor@gmail.com> | 2010-11-13 18:31:58 +0300 |
---|---|---|
committer | Igor <pashev.igor@gmail.com> | 2010-11-13 18:31:58 +0300 |
commit | 66ef9d45417ab4d8c4e0ecbf519e2c751362f85d (patch) | |
tree | 687866d52ce2c6ce36741cab85b8fa01cd3d97f0 | |
parent | d3a5ea2be22e4c5e3e2b0262d1525bf53d54d48e (diff) | |
download | dokuwiki-plugin-papers-66ef9d45417ab4d8c4e0ecbf519e2c751362f85d.tar.gz |
Format author
-rw-r--r-- | bibtex.php | 43 |
1 files changed, 36 insertions, 7 deletions
@@ -161,6 +161,7 @@ class BibtexParser { $text = preg_replace('/([^\\\\])~/u', '\\1 ', $text); $text = preg_replace('/<<(.*?)>>/u', '«\1»', $text); + $text = preg_replace('/``(.*?)\'\'/u', '“\1”', $text); $text = preg_replace('/(\d+)\s*-{1,3}\s*(\d+)/u', '\1–\2', $text); $text = preg_replace('/---/u', '—', $text); $text = preg_replace('/--/u', '–', $text); @@ -348,7 +349,8 @@ class BibtexParserTeam extends BibtexParser protected function format_editor() { $this->format_field_default('editor'); - $this->entry['editor'] = $this->_('Ed. by') . ' ' . $this->entry['editor']; + $this->entry['editor'] = $this->_('Ed. by') + . ' ' . $this->format_author1($this->entry['editor']); } protected function format_volume() @@ -370,10 +372,37 @@ class BibtexParserTeam extends BibtexParser $this->entry['number'] = $this->_('no.') . ' ' . $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(' ', $aa); + return $res; } @@ -448,7 +477,7 @@ class BibtexParserTeam extends BibtexParser protected function format_book() { - $parts = array(); // All parts are connected with '. — ' + $parts = array(); // All parts are joined with '. — ' $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 '. — ' + $parts = array(); // All parts are joined with '. — ' $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 '. — ' + $parts = array(); // All parts are joined with '. — ' if (!empty($this->entry['organization'])) @@ -595,7 +624,7 @@ class BibtexParserTeam extends BibtexParser protected function format_inproceedings() { - $parts = array(); // All parts are connected with '. — ' + $parts = array(); // All parts are joined with '. — ' $part = ''; if (!empty($this->entry['author'])) |