Coder Social home page Coder Social logo

bibcite's Introduction

Bibcite

BibTeX or BibLaTeX like citation for HTML.

Brand new and (probably) full of bugs

Browser Usage

  1. Export your library from your favorite reference management software (e.g. Zotero) in the CSL-JSON format (Detailed Explanation).

  2. Obtain the Javascript file of Bibcite (e.g. from JSDelivr) looking like this

    https://cdn.jsdelivr.net/npm/[email protected]/dist/bibcite.min.js

  3. Assuming you have an exported csl-json file, which we are going to call references.json from now on (but you can use any other filename). And a link to the JS file of bibcite (here called bibcite.js) you can do the following in an html file

    <head>
      <script src="bibcite.js"></script>
      <bib-config bib="references.json"></bib-config>
    </head>
    <body>
      <p>
        This is an example of parenthical citation:
        <bib-cite key="id in references.json"></bib-cite>
      </p>
    
      <bib-references></bib-references>
    </body>

Configuration Options

  1. At the moment there are two citation-styles alphabetic(default) and numeric you can select them like this:

    <bib-config bib="references.json" citation-style="numeric"></bib-config>
  2. There are three types of citations inspired by BibLaTeX \textcite, \parencite and \rawcite. You can set the type of bib-cite to either paren-cite (default) text-cite or raw-cite, e.g.

    <bib-cite key="id_key" type="text-cite"></bib-cite>

Examples

The following body

		<h1>My Page</h1>	
		<p> The next two citations are <code>paren-cite</code> citations
			<bib-cite type="paren-cite" key="mas-colellMicroeconomicTheory1995"></bib-cite>
			<bib-cite type="paren-cite" key="amirEffectsEntryCournot2000"></bib-cite>.
		</p>
		<p>
			The following is a <code>text-cite</code> allowing you to use the name in text
			<bib-cite type="text-cite" key="mas-colellMicroeconomicTheory1995"></bib-cite>.
		</p>
		<p>
			And the remaining two are <code>raw-cite</code>
			<bib-cite type="raw-cite" key="amirEffectsEntryCournot2000"></bib-cite>
			<bib-cite type="raw-cite" key="dsouzaParserExtractionTriples2018"></bib-cite>,
		</p>

		<bib-references></bib-references>

depending on the selected style results in the following pages.

Alphabetic style (Default)

<bib-config bib="references.json" citation-style="alphabetic"></bib-config>

alphabetic style

Numeric style

<bib-config bib="references.json" citation-style="numeric"></bib-config>

numeric style

Author-Year Style

<bib-config bib="references.json" citation-style="author-year"></bib-config>

author-year style

Node Module

You can find bibcite on npm.

Custom Styles

There will be a way to do customization in the future. Styles are Typescript types

// bibcite/styles/types.ts
export type CiteStyle = {
  name: string;
  order: BibOrder;
  enclosing: [string, string];
  multiSeparator: string;
  identifier: (bib_data: Data,index: number, citeType: CiteType) => string;
  bibEntry: (bib_data: Data) => string;
  metaBibEntry: (bibEntry:string, identifier:string) => string;
  metaReference: (content: string) => string;
};

so the numeric style for example is implemented roughly like this:

//bibcite/styles/numeric.ts
export const numeric: CiteStyle = {
  name: "numeric",
  order: { comparison: insertion, inform_citations: true },
  enclosing: ["[", "]"],
  multiSeparator: ",",
  identifier: (_: Data, index: number) => String(index),
  bibEntry: defaultBibEntry,
  metaBibEntry: (bibEntry:string, identifier:string) => `
    <tr style="vertical-align:top">
        <td>[${identifier}]</td>
        <td>${bibEntry}</td>
    </tr>
    `,
  metaReference: (content: string) =>
    `<h2>References</h2>
    <table>
      ${content}
    </table>
    `,
};

and then added

//bibcite/ctyles/index.ts
addStyle(numeric);

So similarly you should be able to define your own custom styles. I still need to figure out how to do plugin loading here though.

bibcite's People

Contributors

felixbenning avatar semantic-release-bot avatar

Stargazers

 avatar Lars Willighagen avatar

Watchers

 avatar

bibcite's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.