Last active
December 15, 2015 13:09
-
-
Save inukshuk/5265227 to your computer and use it in GitHub Desktop.
Generate dependent CSL style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'csl' # gem install csl --pre | |
style = CSL::Style.new do |s| | |
s['class'] = 'in-text' | |
s['default-locale'] = 'en-US' | |
s.title = 'Natura' | |
s.id = 'http://www.zotero.org/styles/natura.csl' | |
# add default self link to id | |
s.self_link! | |
s.independent_parent_link = 'http://www.zotero.org/styles/foobar.csl' | |
s.documentation_link = 'http://natura.com' | |
s.info.issn = '7283-0918' | |
s.info.citation_format = 'numeric' | |
s.info.category = { field: 'biology'} | |
s.info.category = { field: 'physics'} | |
end | |
# style.dependent? #-> true | |
# style.independent_parent #-> would load and parse the parent style | |
# style.valid? #-> would make sure the style is valid | |
# add the default CC license | |
style.default_license! | |
# tag the updated field with the current time | |
style.info.update! | |
# puts style.to_xml #-> would output the style as xml | |
puts style.to_s #-> pretty prints the style as xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<style xmlns="http://purl.org/net/xbiblio/csl" version="1.0" class="in-text" default-locale="en-US"> | |
<info> | |
<title>Natura</title> | |
<id>http://www.zotero.org/styles/natura.csl</id> | |
<issn>7283-0918</issn> | |
<link href="http://www.zotero.org/styles/natura.csl" rel="self"/> | |
<link href="http://www.zotero.org/styles/foobar.csl" rel="independent-parent"/> | |
<link href="http://natura.com" rel="documentation"/> | |
<category citation-format="numeric"/> | |
<category field="biology"/> | |
<category field="physics"/> | |
<updated>2013-03-28 18:33:35 +0100</updated> | |
<rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights> | |
</info> | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should include the xmlns in the style node – that's most likely a bug in the gem version, will be fixed upstream. : )