question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

options with a custom csl template

See original GitHub issue

Hello, I am trying to get citations providing a csl template, but it seems to ignore the template and return a default citation format (apa I think). Is this feature provided? Is something wrong with the following options?

var opt = { format: 'string', type : 'string', style : 'citation', lang : 'en-US', template : <XML_CSL> };

Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
argirokcommented, Mar 15, 2017

It worked! Thanks for the example.

1reaction
larsgwcommented, Mar 14, 2017

v0.3.0-0 isn’t regular v0.3.0 yet; I’m adding requested/important features or API changes step by step. Cite.registerTemplate() isn’t implemented yet.

Anyway, turns out I forgot to mention one detail to make the already weird API work: it only looks for templates if you pass it as an option to .get(). The following works for me. I used a really simple CSL for brevity.

var test = new Cite('[ { id: "Q23571040", type: "article-journal", title: "Correlation of the Base Strengths of Amines 1", DOI: "10.1021/ja01577a030", author: [ { given: "H. K.", family: "Hall" } ], issued: [ { date-parts: [ "1957", "1", "1" ] } ], container-title: "Journal of the American Chemical Society", volume: "79", issue: "20", page: "5441-5444" } ]')

var customTemplate = 
  '<?xml version="1.0" encoding="utf-8"?>' +
    '<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="sort-only" page-range-format="minimal">' +
      '<bibliography>' +
        '<layout>' +
          '<text variable="title"/>' +
        '</layout>' +
      '</bibliography>' +
  '</style>'

var data_a = test.get({		// First call
  format: 'string',
  type: 'string',
  style: 'citation-custom',
  template: customTemplate
})

var data_b = test.get({		// Subsequent calls
  format: 'string',
  type: 'string',
  style: 'citation-custom'
})

I’m really sorry for all the trouble and not providing a working example earlier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSL 1.0.2 Specification
The Citation Style Language (CSL) is an XML-based format to describe the formatting of citations, notes and bibliographies, offering:.
Read more >
Editing CSL Styles - Step-by-Step Guide - Zotero
CSL offers multiple methods to disambiguate cites or names. For example, a style might normally render only the family name (e.g., “(Doe 1999, ......
Read more >
Managing Citation Styles - Ex Libris Knowledge Center
Editing Custom and Out of the Box Styles · Search for and select the style. · To rename the style: double-click the style...
Read more >
Editing Citation Styles - Zotero - Carleton Research Guides
In the Visual Editor, click on Style > Upload Style to upload an existing csl file that you want to edit. In the...
Read more >
Custom citation styles in LaTeX with CSL and Pandoc
It seems that others have recognized the need for more flexible customization and, to be fair, there are other options out there in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found