2.1.0-alpha.3 • Published 3 years ago

markdown-it-attribution-references v2.1.0-alpha.3

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
3 years ago

markdown-it-attribution-references

Attributions and attribution referencing for markdown-it.

Installation

yarn add markdown-it-attribution-references

or

npm install markdown-it-attribution-references

Example

# Markdown

::: attribution cc-by-sa [Markdown](https://en.wikipedia.org/w/index.php?title=Markdown&oldid=975764292) [Wikipedia Authors](https://en.wikipedia.org/w/index.php?title=Markdown&action=history)

Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with Aaron Swartz.
Markdown is often used for formatting readme files, for writing messages in online discussion forums, and to create rich text using a plain text editor.

:::
<h1>Markdown</h1>
<div id="wikipedia-authors-markdown" class="parent">
  <div class="child">
    <p>
      Markdown is a lightweight markup language with plain-text-formatting syntax, created in 2004 by John Gruber with
      Aaron Swartz. Markdown is often used for formatting readme files, for writing messages in online discussion
      forums, and to create rich text using a plain text editor.
    </p>
  </div>
  <p>
    <a href="#wikipedia-authors-markdown" class="anchor">§</a
    ><a href="#wikipedia-authors-markdown" class="label">Attribution 1</a
    ><span
      >Based on: <a href="https://en.wikipedia.org/w/index.php?title=Markdown&amp;oldid=975764292">Markdown</a> by
      <a href="https://en.wikipedia.org/w/index.php?title=Markdown&amp;action=history">Wikipedia Authors</a>, License:
      <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons: Attribution-ShareAlike 4.0</a></span
    >
  </p>
</div>
<h2 id="list-of-attributions" class="list">List of Attributions</h2>
<ol class="list">
  <li class="item">
    <a href="#wikipedia-authors-markdown" class="label">Attribution 1</a>:
    <a href="https://en.wikipedia.org/w/index.php?title=Markdown&amp;oldid=975764292">Markdown</a> (By:
    <a href="https://en.wikipedia.org/w/index.php?title=Markdown&amp;action=history">Wikipedia Authors</a>,
    <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons: Attribution-ShareAlike 4.0</a>
  </li>
</ol>

Usage

const md = require("markdown-it")().use(require("markdown-it-attribution-references"), opts);

See a demo as JSFiddle.

The opts object can contain:

NameDescriptionDefault
afterRule name to insert new rules after.false
nsNamespace for saving registered attributions (env)."attributions"
wrapWrapper options.see below
anchorAnchor options.see below
labelLabel options.see below
listList options.see below
attributionAttribution options.see below

The wrap object can contain:

NameDescriptionDefault
parentParent wrapper options.see below
childChild wrapper options.see below

The parent object can contain:

NameDescriptionDefault
tagHTML tag for parent."div"
classParent wrapper class."parent"

The child object can contain:

NameDescriptionDefault
enableWrap attributed content.true
tagHTML tag for child."div"
classChild wrapper class."child"

The anchor object can contain:

NameDescriptionDefault
enableInsert anchor before attribution label.true
contentAnchor content."§"
classAnchor class."anchor"

The label object can contain:

NameDescriptionDefault
enableInsert attribution label before figure caption.true
textAttribution label text."Attribution #"
placeholderAttribution number placeholder."#"
classAttribution label class."label"

The list object can contain:

NameDescriptionDefault
enableAppend list of attributions.true
classList of attributions class."list"
titleList title."List of Attributions"
tagHTML tag for list."ol"
itemList item optionssee below

The item object can contain:

NameDescriptionDefault
tagHTML tag for list item."li"
hrefAdd target id to list item label.true
classList item class."item"
labelInsert attribution label.true
textList title pattern."<title> (By: <author>, <license>)"

The attribution object can contain:

NameDescriptionDefault
topInsert attribution at top, before child (attributed content).false
terminatorTerminator for attribution open/close.":::"
labelTerminator followed by attribution open."attribution"
textAttribution title pattern."Based on: <title> by <author>, License: <license>"
licensesArray of license objects.[ see below ]

Each license objects can contain:

NameDescriptionExample
idIdentifier used for attributions."cc-by"
shortShort license name."CC BY"
nameFull license name."Creative Commons: Attribution"
versionLicense Version."4.0"
urlLicense related URLs.{ deeds, legalCode }

An extensive list of possible license agreements can be found at Comparison of free and open-source software licences.

License

GPL-3.0 © StudyATHome Internationally