Skip to content

An extension of PHP League's CommonMark library to enable abbreviation usage.

License

Notifications You must be signed in to change notification settings

8fold/commonmark-abbreviations

Repository files navigation

8fold Abbreviations for CommonMark

This library is an extension for the CommonMark parser from the PHP League adding abbreviation syntax and rendering to Markdown.

Warning: This text is written using that syntax enabling extension testing; therefore, it will most likely not render as intended without a rendering extension using this syntax.

Installation

composer require 8fold/commonmark-abbreviations

Usage

2.1.0 to 3.0.0

[.Eightfold](8fold)

Becomes:

<abbr title="Eightfold">8fold</abbr>

You MAY also use the syntax prior to 2.1.0.

2.0.0 and before

[.8fold](Eightfold)

Becomes:

<abbr title="Eightfold">8fold</abbr>

The syntax

Inspired by the link syntax - []() - and the footnote syntax in the extension from MultiMarkdown - [^].

The syntax is a square bracket followed by a period or dot: [.]().

Just like the footnote indicates superscript, the abbreviation syntax was found to indicate shortening to more people than previously proposed options. Placing the dot inside the opening square bracket allows the abbreviation to exist next to other glyphs as opposed to forcing empty space. (A conversation in the [CommonMark .Spec board](https://talk.commonmark.org/t/abbreviations-and-acronyms/890) was also referenced, and informative.)

Given the traditional use of the abbr tag commonly combined with the title attribute, the link syntax makes sense as the a tag combines inner text with href and the img tag uses two attributes, src and alt to be valid and accessible.

Replace-all .vs. inline

We decided to go with inline, single instance over footer, replace-all.

Two main options exist for implementing this capability.

The first is to place the abbreviation and definition at the bottom of the document and render all occurrences of the abbreviation with the abbr element and title. The drawback here is possible impact to readers using [.AT](Assistive Technology) like screen readers; potentially being read the full abbreviation each time.

The second option is to have the abbreviation be inline with the surrounding text. The drawback here is the need to write more each time an author uses the abbreviation.

This library looks at Markdown as being a way of writing potentially rich-text documents first, which can be transformed into .Hypertext Markup Language or something else. The recommendation from the [.US](United States) Plain Language Guidelines is to avoid abbreviations and acronyms in general and specifically to:

  • Try to keep them to a maximum of two a page.
  • Use them if spelling them out would annoy your readers.
  • If you must use an abbreviation or acronym, spell it out the first time you use it. For example: [.CBT](Computer-based training).

As a document editor and author, I tend to recommend defining "first use" as "first use per section," where "section" is further defined as beginning with a header; so, if writing a 20 page document and an abbreviation is defined on page one, it's poor [.UX](user experience) to require a reader on page 20 to turn back to page one to jog their memory of the abbreviation's definition. This also speaks to the definitions being at the end of the document, similar to a glossary.

About

An extension of PHP League's CommonMark library to enable abbreviation usage.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  
  •  

Packages

No packages published