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.

Style inheritance and dependent styles.

See original GitHub issue

I’m new to CSL and as I understand it there is no style inheritance mechanism. That is, the ability to have a smaller csl file with a few modifications to citation and bibliography styles that are contained in a base csl file.

There are “dependent styles”, http://docs.citationstyles.org/en/stable/specification.html#dependent-styles

A dependent style is an alias for an independent style. Its contents are limited to style metadata, and doesn’t include any formatting instructions (the sole exception is that dependent styles can specify an overriding style locale).

… but that just aliases the parent style and there’s not room for providing overriding styles.

From https://github.com/citation-style-language/styles/wiki/Style-Requirements

If you started from another CSL style, delete the original style authors and contributors, and point to the original style with a “template” link:

<info>
  <link href="http://www.zotero.org/styles/original-style" rel="template"/>
</info>

… that suggests rel="template" serves as a mere informational reference.

If I’m right there’s no style inheritance mechanism would there be appetite for this as a feature request?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:1
  • Comments:44 (26 by maintainers)

github_iconTop GitHub Comments

3reactions
bdarcuscommented, Apr 25, 2021

IIRC, the decision wasn’t primarily related to xslt.

You’re right. Here’s the issue:

https://github.com/citation-style-language/csl-evolution/issues/15

There weren’t strong feelings one way or the other, so we erred for conservatism.

2reactions
wyhcommented, Sep 10, 2021

I read through the long thread which was opened several years ago. I realized this issue after manually edited two CSL styles recently, and this is why I’m here.

After searching CSL inheritance for some time, I found CSL dependence actually has no relation with inheritance.

I’m a python developer, and I want to introduce you the jinja template I adopted at the beginning of my career. Jinja (now version 3.0) is a sharping tool for templates that could extend parent templates and include children.

So basically I split the parent style (For example, APA) into several module templates. The template folder has a tree structure, such as:

APA/
       style.xml
       head.xml
       author_date.xml
       container.xml
       citation.xml
       bibliography.xml

And for example, I want to edit a new style which is based on APA, I would edit the new style.xml as :

{% extends 'apa/style.xml' %}

{% block head %}

     make  modifications

{% endblock head %}

{% block author_date $}

customizations

{% endblock %}

And finally, we have a python script to compile templates to strings and saved to the new style.xml.


from jinja import template

@task 
def compile(style_name):
    new_style = template(style_name)
    style_file = open(style_name.xml, 'w')
    style_file.write(new_style.render())
    style_file.close()

So we could get a new style that extends from APA. I haven’t open sourced all of my styles, but I make this philosophy available in my team to make style writing(modification) plausible.

Just for your reference.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cascade, specificity, and inheritance - Learn web development
CSS styles declared outside of any layer are combined together, in the order in which those styles are declared, into an unnamed layer,...
Read more >
Understanding CSS Inheritance (Inherit, Initial, Unset, and ...
When you style a parent element, in some cases the style will be inherited by its children elements. I say some cases because...
Read more >
Chapter 1. Cascade, specificity, and inheritance - CSS in Depth
The four parts that make up the cascade; The difference between the cascade and inheritance; How to control which styles apply to which...
Read more >
Inheritance - CSS - Codecademy
Inheritance describes how certain styles are initialized or computed depending on the CSS property and whether a value was set.
Read more >
CSS Cascading and Inheritance Level 4 - W3C
All document language-based styling must be translated to corresponding CSS rules and enter the cascade as rules in either the UA-origin or a ......
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