aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README4
-rw-r--r--bibtex.php31
-rw-r--r--test.php11
3 files changed, 34 insertions, 12 deletions
diff --git a/README b/README
index 23f95fd..5ab9e1b 100644
--- a/README
+++ b/README
@@ -9,10 +9,6 @@ It introduces two syntax extentions for Dokuwiki:
Raw BiBTeX data
</bibtex>
-1.1 Notes
-
-For final output to be valid XHTML
-no empty line are allowed before </bibtex>
diff --git a/bibtex.php b/bibtex.php
index 13796e9..7f36063 100644
--- a/bibtex.php
+++ b/bibtex.php
@@ -185,6 +185,37 @@ class BibtexParser
}
+ /*
+ * Export sorted BiBTeX.
+ * Do not use after $this->expand_years()
+ *
+ */
+ public function export()
+ {
+ $res = '';
+ $this->sort();
+ foreach ($this->STRINGS as $key => $value)
+ {
+ $res .= '@STRING (' . $key . '="' . $value . '")' . "\n";
+ }
+
+ $res .= "\n\n";
+
+ foreach ($this->ENTRIES as $ent)
+ {
+ $res .= '@' . mb_strtoupper($ent['entry']) . ' {' . $ent['id'] . ",\n";
+ $fields = array();
+ foreach($ent as $key => $value)
+ {
+ // Skip our special fields
+ if (!in_array($key, array('id', 'entry')))
+ $fields[] = mb_strtoupper($key) . '=' . $value;
+ }
+ $res .= implode(",\n", $fields);
+ $res .= "\n}\n\n";
+ }
+ return $res;
+ }
}
diff --git a/test.php b/test.php
index f6d51f7..9ef35df 100644
--- a/test.php
+++ b/test.php
@@ -1,15 +1,10 @@
<?php
require_once('bibtex.php');
-$bibtex = new BibtexParserGoga();
-$bibtex->read_file('example.bib');
-$bibtex->select(array(
- 'author' => '/pashev/',
- ));
+$bibtex = new BibtexParserTeam();
+$bibtex->read_file('1.bib');
+print $bibtex->export();
-print_r($bibtex->STRINGS);
-print_r($bibtex->SELECTION);
-
?>