# Citation Formatter

**URL:** <https://gramps.discourse.group/t/citation-formatter/3973>\
**Category:** Beta Testing\
**Created:** [August 11, 2023, 12:27am UTC](https://gramps.discourse.group/t/citation-formatter/3973 "2023-08-11T00:27:51Z")\
**Posts on this page:** 14\
**Page:** 2

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [September 2, 2023, 10:40pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/21 "2023-09-02T22:40:02Z")

</div>

> [@Nick-Hall](#):
>
> You may also want to change the description to match the name.

Done and pushed to the PR

---

<div class="post-metadata">

**Author:** ![StoltHD](https://avatars.discourse-cdn.com/v4/letter/s/db5fbb/32.png) [@StoltHD](https://gramps.discourse.group/u/StoltHD)\
**Post date:** [April 2, 2024, 2:49pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/23 "2024-04-02T14:49:08Z")

</div>

> [@DaveSch](#):
>
> Even within the Chicago style, the format changes depending on the type of source. For a book, the title should be in italics. Gramps cannot do this (or can it?). While articles or parts of a larger source has the title in quotations. Currently we can only have one format for everything.

By using CSL it will be the CSL definition file that holds all the different formats for different sources…  
All Gramps as a software need to do is to read the correct style and format for the different types.

And if Gramps as a project creates its own Citation Style, it can be sent back to the CSL organisation with a request to add it to the database of formats, CSL also support translations that can be added to the style…

PS. I do know that it is a little more than “just …” to make this working, but the features are already defined in the CSL style used, regardless of if it is APA, Chicago, or any other style.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [April 2, 2024, 3:10pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/24 "2024-04-02T15:10:39Z")

</div>

In 5.2, the Citation plugin is a Global preference selection.

Is there a way to make a CITE plugin override (similar to the Name format and grouping can be overridden for an individual or a surname)?

Does the Citation plugin specification allow a FALLBACK to the Preference CITE plugin if criteria are not met?

2 examples:

- For all my Serial/Periodicals (or similarly ephemeral website sources), a different CITE formatter plugin is desireable. But these are exceptions or “edge cases”, unless specifed otherwise, the Preferences CITE plugin.
- if a Source (or Citation) had a specifically named Attribute (for inline, footnote, or endnote format) with hard‐coded Citation, then could the Preferences CITE selection be ignored?

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [April 2, 2024, 3:51pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/25 "2024-04-02T15:51:00Z")

</div>

> [@emyoulation](#):
>
> Is there a way to make a CITE plugin override

I envisioned having the Style selected in Preferences, i.e. [Chicago](https://www.citationmachine.net/chicago). Then for each Source, it would self-select its formatting from within the master Style based upon the Media Type from its Repository or manually set by the user. A Book source could have a different format than a magazine or electronic source.

The Citation may need an override for the best output option. Maybe have the citation editor display how it would actually appear in a report.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [April 2, 2024, 3:51pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/26 "2024-04-02T15:51:35Z")

</div>

Reports generate a bibliography object and pass it to a CITE plugin. The bibliography object contains lists of source and citation handles for which a text representation is required.

A CITE plugin can generate the formatted citations in various ways. The legacy plugin just combines a few fields from the source and citation objects. A CSL formatter could take CSL variables stored in attributes and pass them to a library such as [citeproc-py](https://pypi.org/project/citeproc-py/).

So you could write a CITE plugin to look for hard-coded citations stored in attributes. It could also look for a format string in an attribute that could be used to build a formatted citation from other attributes.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [April 2, 2024, 4:07pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/27 "2024-04-02T16:07:27Z")

</div>

> [@DaveSch](#):
>
> I envisioned having the Style selected in Preferences, i.e. [Chicago](https://www.citationmachine.net/chicago). Then for each Source, it would self-select its formatting from within the master Style based upon the Media Type from its Repository or manually set by the user. A Book source could have a different format than a magazine or electronic source.

The style name would have to be specified in a configuration file, but you should be able to do all of this in v5.2.

---

<div class="post-metadata">

**Author:** ![DaveSch](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/davesch/32/40_2.png) [@DaveSch](https://gramps.discourse.group/u/DaveSch)\
**Post date:** [April 2, 2024, 4:31pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/28 "2024-04-02T16:31:33Z")

</div>

> [@Nick-Hall](#):
>
> The style name would have to be specified in a configuration file, but you should be able to do all of this in v5.2.

A Style can be set in Preferences.

But within any given style it dictates that a book has one format:

Sam Staggs, _Born to Be Hurt: The Untold Story of Imitation of Life_ (New York: St. Martin’s Press, 2009), 84.

while a magazine article is different:

First name, Last name of Chapter Author, “Chapter or Article Title,” in _Book Title_ , ed. First Name Last Name of Editor (Publication Place: Publisher, Year), page range.

These two examples are both [Chicago](https://www.citationmachine.net/chicago) style. And there are others,

Currently 5.2 allows only one option (yes selected by the user) to be printed in a report regardless of the type of the source.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [April 2, 2024, 5:07pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/29 "2024-04-02T17:07:19Z")

</div>

In my testing I used the style “chicago-fullnote-bibliography” and I hard-coded the CSL style to “article”, but you could store it in an attribute.

I have written some code that converts a Gramps citation object into JSON suitable for CSL input. The styles are available as XML files.

If anyone is interested in developing this further I can give them my experimental code.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [April 12, 2024, 8:30pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/30 "2024-04-12T20:30:06Z")

</div>

The wiki needs some documentation for the use of the [CITE (citation formatter)](https://gramps-project.org/wiki/index.php/Addon_list_legend#cite) plugins. Created a [landing page](https://gramps-project.org/wiki/index.php/Plugin:Citation_Formatter#Citation_Formatter) but it needs some illustrations.

The **Enhanced citation formatter** is supposedly the same as the **Legacy** version except that it includes the Repository Title (labeled “Name” in the Repository object editor) and Call Number.

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/4/4421bdcd4bc6825a7fea9b4c092a1cd4488e3232.png)

Could the [Biography quickview](https://github.com/gramps-project/addons-source/tree/master/BiographyQuickview) addon be modified as an example of how to use the CITE formatter?

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/5/5bf85f5a8464f407b627d602b07d0202eb2c93f6.png)

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [April 12, 2024, 8:44pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/31 "2024-04-12T20:44:02Z")

</div>

The citation formatters are still experimental. They format [Bibliography](https://github.com/gramps-project/gramps/blob/master/gramps/gen/plug/report/_bibliography.py#L119) objects used in reports.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [April 12, 2024, 9:28pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/32 "2024-04-12T21:28:24Z")

</div>

> [@Nick-Hall](#):
>
> The citation formatters are still experimental. They format [Bibliography](https://github.com/gramps-project/gramps/blob/master/gramps/gen/plug/report/_bibliography.py#L119) objects used in reports

QuickView reports are still reports. Wouldn’t the Biography be a good representation of the use of a citation formatter of a Bibliography and its output? It would have far less latency than generating a full report and then viewing it.

Users could use the Quick View gramplet to aid validation of the selection.

Having immediate feedback in the Preferences when selecting a “Citation formatter” would probably be unsafe. (Similar to the feedback when creating a new format in the Display Name Editor.) Because if there was a fatal error rendering the sample citation/source/repository using the selected Citation Format, then the interface would be inaccessible for switching to another format.

---

<div class="post-metadata">

**Author:** ![Nick-Hall](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/nick-hall/32/95_2.png) [@Nick-Hall](https://gramps.discourse.group/u/Nick-Hall)\
**Post date:** [April 12, 2024, 9:31pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/33 "2024-04-12T21:31:58Z")

</div>

Any code can use a citation formatter. Just pass it a Bibliography object and it will return formatted results.

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [April 12, 2024, 10:58pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/34 "2024-04-12T22:58:01Z")

</div>

OK. So the Reports that reference a Bibliography are:

### Builtins:

- Detailed Ancestral Report [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/textreport/detancestralreport.py#L63) text report
- Detailed Descendant Report [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/textreport/detdescendantreport.py#L70) text report
- Family [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/family.py#L53) web report
- Individual Complete [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/textreport/indivcomplete.py#L68) text report
- Person [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/person.py#L66), base page [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/basepage.py#L86), Place [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/place.py#L53), Media [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/media.py#L58), Statistics [source](https://github.com/gramps-project/gramps/blob/6b758b8067dc47daa718e1ddf45da40578c54866/gramps/plugins/webreport/statistics.py#L52) web report

### Addons:

- Person Everything [source](https://github.com/gramps-project/addons-source/blob/ddb32eb151794e5b156aeace00a43bd9d6db57cc/PersonEverything/PersonEverything.py#L775)
- Detailed Descendant Report [source](https://github.com/gramps-project/addons-source/blob/ddb32eb151794e5b156aeace00a43bd9d6db57cc/DetDescendantReport-images/detdescendantreporti.py#L203)
- Dynamic Web [source](https://github.com/gramps-project/addons-source/blob/ddb32eb151794e5b156aeace00a43bd9d6db57cc/DynamicWeb/dynamicweb.py#L191)
- Detailed Descendant Book Report [source](https://github.com/gramps-project/addons-source/blob/ddb32eb151794e5b156aeace00a43bd9d6db57cc/DescendantBooks/DetailedDescendantBookReport.py#L52)

---

<div class="post-metadata">

**Author:** ![emyoulation](https://yyz2.discourse-cdn.com/free1/user_avatar/gramps.discourse.group/emyoulation/32/67_2.png) [@emyoulation](https://gramps.discourse.group/u/emyoulation)\
**Post date:** [April 12, 2024, 11:19pm UTC](https://gramps.discourse.group/t/citation-formatter/3973/35 "2024-04-12T23:19:07Z")

</div>

> [@emyoulation](#):
>
> Detailed Descendants Report [source](https://github.com/gramps-project/addons-source/blob/ddb32eb151794e5b156aeace00a43bd9d6db57cc/DetDescendantReport-images/detdescendantreporti.py#L203)

**Legacy** citation formatter

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/f/f2eb03a48b781b2e561d997c07cd86ba4118cf62.png)

**Enhanced** citation formatter

 ![image](https://global.discourse-cdn.com/free1/uploads/gramps/original/2X/c/cc940b79bee050ccc9f92bffff06233bf3d826ec.png)

[Previous page](https://gramps.discourse.group/t/citation-formatter/3973.md?page=1)
