Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:citation_styles:style_editing_step-by-step [2013/04/04 18:20] – [Editing CSL Styles - Step-by-step Guide] adamsmithdev:citation_styles:style_editing_step-by-step [2023/01/07 17:37] (current) – [3 - Install your Edited Style with Zotero] dstillman
Line 1: Line 1:
-======Editing CSL Styles - Step-by-step Guide======+======Editing CSL Styles - Step-by-Step Guide======
  
  
Line 5: Line 5:
  
 An open source, visual CSL editor has been developed in a collaboration of Columbia University Library and Mendeley. You can find the editor [[http://editor.citationstyles.org/about/|here]] An open source, visual CSL editor has been developed in a collaboration of Columbia University Library and Mendeley. You can find the editor [[http://editor.citationstyles.org/about/|here]]
-and a usage guide [[https://github.com/citation-style-editor/csl-editor/wiki/User-guide-for-the-CSL-Editor|here]]. If you have trouble editing styles you can still ask them on the Zotero forums. You can report bugs [[https://github.com/citation-style-editor/csl-editor/issues|here]] - make sure you're reporting reproducible errors. The github issue tracker is not the place for questions. +and a usage guide [[https://github.com/citation-style-editor/csl-editor/wiki/User-guide-for-the-CSL-Editor|here]]. If you have trouble editing styles you can still ask for help on the Zotero forums. You can report bugs [[https://github.com/citation-style-editor/csl-editor/issues|here]] - make sure you're reporting reproducible errors. The github issue tracker is not the place for questions.
-===== 1 - Start with the Right Style =====+
  
-Start by checking the [[/styles|Zotero Style Repository]]. If you want to improve an existing CSL style, make sure that you start from the most recent version (the repository shows the date and time each style was last updated). If you want to create a new style, find the style that most closely matches what you need using the previews in the style repository (check "Show only unique styles" to avoid seeing duplicates)You can also use the [[dev/citation_styles/preview_pane|Zotero Preview pane]] to compare installed styles using items from your local Zotero library.+=====Manually Editing CSL styles===== 
 +In many cases you may still want to manually edit CSL styles. This guide provides easy to follow steps.
  
-**Important** If you have ever used Zotero 2.0 or an earlier version on your computer, your [[/support/zotero_data|Zotero data directory]] probably still contains styles in the CSL 0.8.format. While Zotero 2.1 and newer still supports this older format, it is strongly recommended to always start with an up-to-date style CSL 1.0 style from the [[/styles|Zotero Style Repository]], or, if you want to make changes to a CSL 0.8.1 style not present in the style repository, to first [[http://citationstyles.org/downloads/upgrade-notes.html#updating-csl-0-8-styles|update it to CSL 1.0]].+==== - Start with the Right Style ====
  
-===== 2 - Edit the Style =====+Start by checking the [[/styles|Zotero Style Repository]]. If you want to improve an existing CSL style, make sure that you start from the most recent version (the repository shows the date and time each style was last updated). If you want to create a new style, find the style that most closely matches what you need using the previews in the style repository. 
 +Typically the best way to find a most similar style is the "[[http://editor.citationstyles.org/searchByExample/|search by Example]]" function of the visual style editor.  
 + 
 +==== 2 - Edit the Style ====
  
 Download the style you want to edit to your computer, and open it in a (plain) text editor like Notepad on Windows, TextEdit on Mac OS X (select "Make Plain Text" under "Format"), or gedit in Linux. Other options are [[http://notepad-plus-plus.org/|Notepad++]] for Windows, [[http://www.barebones.com/products/TextWrangler/|TextWrangler]] for Mac OS X, [[http://www.oxygenxml.com/|oXygen XML Editor]], [[http://www.thaiopensource.com/nxml-mode/|Emacs in nXML mode]], and [[http://www.jedit.org/|jEdit]], which all support XML syntax highlighting (CSL is an XML-based language) and in some cases also real-time [[https://github.com/citation-style-language/styles/wiki/Validation|validation against the CSL schema]]. Download the style you want to edit to your computer, and open it in a (plain) text editor like Notepad on Windows, TextEdit on Mac OS X (select "Make Plain Text" under "Format"), or gedit in Linux. Other options are [[http://notepad-plus-plus.org/|Notepad++]] for Windows, [[http://www.barebones.com/products/TextWrangler/|TextWrangler]] for Mac OS X, [[http://www.oxygenxml.com/|oXygen XML Editor]], [[http://www.thaiopensource.com/nxml-mode/|Emacs in nXML mode]], and [[http://www.jedit.org/|jEdit]], which all support XML syntax highlighting (CSL is an XML-based language) and in some cases also real-time [[https://github.com/citation-style-language/styles/wiki/Validation|validation against the CSL schema]].
  
-Paste the style code into the [[/support/dev/citation_styles/reference_test_pane|Zotero Reference Test pane]], so you instantly see the effect of code changes on the style output. If you make your edits directly in the test pane, save your edits often via your text editor, as changes in the test pane get easily lost.+Paste the style code into the [[/support/dev/citation_styles/reference_test_pane|Zotero CSL Editor]], so you instantly see the effect of code changes on the style output. If you make your edits directly in the test pane, save your edits often via your text editor or using the "Save" button {{:dev/citation_styles/csledit-save.png}}, as changes in the test pane get lost easily.
  
 See the [[http://citationstyles.org/citation-style-language/documentation/|documentation page]] of the CSL project website for information on making CSL changes (in particular, make sure to take a look at the [[http://citationstyles.org/downloads/specification.html|CSL specification]]. Below we discuss a few common and simple style edits to get you started. See the [[http://citationstyles.org/citation-style-language/documentation/|documentation page]] of the CSL project website for information on making CSL changes (in particular, make sure to take a look at the [[http://citationstyles.org/downloads/specification.html|CSL specification]]. Below we discuss a few common and simple style edits to get you started.
  
-==== Examples Edits ====+=== Change the Style Title and ID === 
 + 
 +**Important:** Before installing your edited style, you must change the style title and ID at the top of the style code. If you don't change these, your modified style will be overwritten the next time the original style is updated. 
 + 
 +The style title and ID are stored within the ''<title/>'' and ''<id/>'' elements near the top of the style. For example, 
 + 
 +<code><title>American Psychological Association 6th edition</title> 
 +<title-short>APA</title-short> 
 +<id>http://www.zotero.org/styles/apa</id></code> 
 + 
 + 
 +can be changed to 
 + 
 +<code><title>American Psychological Association 6th edition Modified</title> 
 +<title-short>APA</title-short> 
 +<id>http://www.zotero.org/styles/apa-modified</id></code> 
 + 
 +The URLs that you put in as an ID do not have to exist (i.e., you can use a zotero.org/style/mystyle type ID even if the style will not be posted on the Zotero repository). 
 + 
 +=== Validation === 
 + 
 +Before installing a modified style, always make sure it is valid XML and CSL by [[https://github.com/citation-style-language/styles/wiki/Validation|validating against the CSL schema]]. 
 + 
 +=== Examples Edits ====
  
-===Changing Punctuation===+==Changing Punctuation==
  
 In this example, we want to display the publisher ("CSHL Press") and the location of the publisher ("Cold Spring Harbor, NY") in a bibliographic entry. While this can be achieved with the code In this example, we want to display the publisher ("CSHL Press") and the location of the publisher ("Cold Spring Harbor, NY") in a bibliographic entry. While this can be achieved with the code
Line 49: Line 75:
 you would lose the closing bracket, i.e. "(CSHL Press". you would lose the closing bracket, i.e. "(CSHL Press".
  
-=== Changing Et-al Abbreviation ===+== Changing Et-al Abbreviation ==
  
 There are two main settings for et-al abbreviation (e.g., rendering the names "Doe, Smith & Johnson" as "Doe et al."). The minimum number of names that activates et-al abbreviation, and the number of names shown before "et al.". There are two main settings for et-al abbreviation (e.g., rendering the names "Doe, Smith & Johnson" as "Doe et al."). The minimum number of names that activates et-al abbreviation, and the number of names shown before "et al.".
Line 65: Line 91:
 will result in name lists like "Doe", "Doe & Smith" and, if there are three or more names, "Doe et al.". Try changing these numbers and observe the effect. will result in name lists like "Doe", "Doe & Smith" and, if there are three or more names, "Doe et al.". Try changing these numbers and observe the effect.
  
-===Changing Disambiguation===+==Changing Disambiguation==
  
 CSL offers multiple methods to disambiguate cites or names. For example, a style might normally render only the family name (e.g., "(Doe 1999, Doe 2002)"). If the authors are Jane Doe and Thomas Doe, these names can be disambiguated by adding initials or the full given names (e.g., "(J. Doe 1999, T. Doe 2002)"). CSL offers multiple methods to disambiguate cites or names. For example, a style might normally render only the family name (e.g., "(Doe 1999, Doe 2002)"). If the authors are Jane Doe and Thomas Doe, these names can be disambiguated by adding initials or the full given names (e.g., "(J. Doe 1999, T. Doe 2002)").
Line 85: Line 111:
 </code> </code>
  
-==== Change the Style Title and ID ==== 
  
-Before installing your edited style, change the title and ID of your style if you don't want your modified style to overwrite the original style.+==Separation of authors==
  
-The style title and ID are stored within the ''<title/>'' and ''<id/>'' elements near the top of the styleFor example,+By default several authors are separated by a delimiter '''' and the word ''and''This settings can be changedfor example to use the symbol ''&'' instead:
  
-<code><title>Harvard Reference format 1 (Author-Date)</title>  +<code xml> 
-<id>http://www.zotero.org/styles/harvard1</id></code>+<names variable="author"> 
 +  <name form="short" and="symbol" delimiter=", "/> 
 +  ..
 +</names> 
 +</code>
  
-can be changed to+or to not use ''and'' at all, but to use the delimiter ''/'':
  
-<code><title>Harvard Style Modified</title+<code xml> 
-<id>http://www.zotero.org/styles/harvard-modified</id></code>+<names variable="author"> 
 +  <name form="short" delimiter="/"/> 
 +  .. 
 +</names> 
 +</code>
  
-The URLs that you put in as an ID do not have to exist, i.e. you can use a zotero.org/style/mystyle type ID even if the style will not be posted on the Zotero repository.+== Conditional Rendering (full footnote style) ==
  
-==== Validation ====+The appearance of citations in (full) footnote styles may depend on their position in the paper. If the same source is cited twice, it may be that a shortened version is used in the second (and any further) citation. To handle this distinction, one can use [[http://citationstyles.org/downloads/specification.html#choose|conditional rendering based on the position]] of the citation. A generic structure could then look as
  
-Before installing modified style, always make sure it is valid XML and CSL by [[https://github.com/citation-style-language/styles/wiki/Validation|validating against the CSL schema]].+<code xml> 
 +<citation> 
 +  <layout> 
 +    <choose> 
 +      <if position="ibid-with-locator"> 
 +        ... 
 +      </if> 
 +      <else-if position="ibid"> 
 +        ... 
 +      </else-if> 
 +      <else-if position="subsequent"> 
 +        ... 
 +      </else-if> 
 +      <else> 
 +        ... 
 +      </else> 
 +    </citation> 
 +  </layout> 
 +</citation> 
 +</code> 
 + 
 +If case is missing in your style, you can add that and fill out what and how the information should be rendered in that case ([[https://www.zotero.org/styles/chicago-fullnote-bibliography?source=1|an example of such a full footnote style]]). 
 + 
 +==== 3 - Install your Edited Style with Zotero ====
  
-===== 3 - Install your Edited Style with Zotero ===== +See [[/support/styles|Citation Styles]].
-====Zotero for Firefox==== +
-Save the style with a ".csl" file extension (you can generally do this by simply typing ".csl" after the name of your file) , and drag-and-drop the CSL style file onto an open Firefox browser window, and click the "Install" button (you can ignore the grey bar at the top of the window ("This XML style does not appear...")).+
  
-{{:style_install.png?600}}+Save the style with a ".csl" file extension (you can generally do this by simply typing ”.csl” after the name of your file). Then, go to the [[/support/preferences/cite|Cite pane]] in the Zotero [[/support/preferences|preferences]]. Click on the "+" sign below the list of installed styles. In the file selection dialogue that opens, navigate to the .csl file you just created and open it. This will install your new style into the Zotero data directory.
  
-====Zotero Standalone==== +==== 4 - Sharing Styles ====
-Save the style with a ".csl" file extension (you can generally do this by simply typing ”.csl” after the name of your file). Then, go to the [[/support/preferences/cite|"Cite" tab]] in the Zotero [[/support/preferences|preferences]]. Click on the + sign below the list of installed styles. In the file selection dialogue that opens, navigate to the .csl file you just created and open it. This will install your new style. +
-===== 4 - Sharing Styles =====+
  
-If you think that your modified style might be useful to other people, consider [[https://github.com/citation-style-language/styles/wiki/Submitting-Styles|submitting]] it to the [[/styles|Zotero Style Repository]].+If you think that your modified style might be useful to other people, consider [[https://github.com/citation-style-language/styles/blob/master/CONTRIBUTING.md|submitting]] it to the [[/styles|Zotero Style Repository]].
  
-===== Getting Help =====+==== Getting Help ====
  
-If you get stuck at any point, try searching the [[/forum/|Zotero forums]], or, if that doesn't give an answer, post in the forum's [[/forum/11/|styles section]]. +If you get stuck at any point, try posting a question on the [[/forum/|Zotero forums]]. 
dev/citation_styles/style_editing_step-by-step.1365114005.txt.gz · Last modified: 2013/04/04 18:20 by adamsmith