lib/bibtex2html/convert.rb in bibtex2html-0.1.0 vs lib/bibtex2html/convert.rb in bibtex2html-0.2.0
- old
+ new
@@ -1,11 +1,26 @@
-# -+- coding: utf-8 -*-
require "bibtex2html/version"
require "bibtex"
+require "cgi"
module Bibtex2html
+ module_function
+
def convert item
+ doc = "<div class='bibitem'>"
bibitem = BibTeX.parse item
- p bibitem
+ bibitem.each do |attributes|
+ attributes.each do |key, values|
+ doc += "<h3>#{CGI.escapeHTML key.to_s}</h3>"
+ doc += "<ul>"
+
+ values.to_a.each do |value|
+ doc += "<li>#{CGI.escapeHTML value}</li>"
+ end
+ doc += "</ul>"
+ end
+ end
+ doc += "</div>"
+
return doc
end
end