larsgw / citation.js

Citation.js converts formats like BibTeX, Wikidata JSON and ContentMine JSON to CSL-JSON to convert to other formats like APA, Vancouver and back to BibTeX.
https://citation.js.org/
MIT License
219 stars 30 forks source link

MLA In-Text Citations #226

Closed AlexeyShaykov closed 12 months ago

AlexeyShaykov commented 12 months ago

Hi. Thank for your works.

Here is my example https://codesandbox.io/s/citation-js-format-sample-forked-r2l5fs?file=/src/App.js where I try to make citations in diff formats. Such some custom MLA citation format from file https://github.com/citation-style-language/styles/blob/master/modern-language-association.csl

In doc https://owl.purdue.edu/owl/research_and_citation/mla_style/mla_formatting_and_style_guide/mla_in_text_citations_the_basics.html

MLA format use page In-text citations, in my exaple in JSON I have page: "5441-5444" field for this I ask about this case https://github.com/citation-style-language/styles/issues/6667

they say:

I've just added a locator to the CSL JSON in your snippet, but that didn't work. Might be that citation-js is just not handling locators?

Can u please help me? how to pass page in MLA format In-Text Citations?

larsgw commented 12 months ago

You have added page: "5441-5444" but that field specifies the page numbers of the entire article. To include page numbers in a citation, use the following snippet (adapted from your example):

citationMLA: reference.format("citation", {
  template: "mla",
  entry: [
    {
      id: "Q922203",
      locator: "5441-5444"
    }
  ],
  format
}),
AlexeyShaykov commented 12 months ago

@larsgw thx a lot! works amazing!

larsgw commented 12 months ago

Great!