Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Abbreviation (abbr) element in reStructuredText

How to generate an <abbr> abbreviation element in ReST?

<abbr title="Hypertext Markup Language">HTML</abbr>

The documentation indicates that "The abbreviation element is not exposed in default restructured text. It can only be accessed through custom roles." I'm not sure how to create such a custom role, and the rest of the documentation is a tad obscure to me.

like image 537
Emilien Avatar asked Jan 07 '16 01:01

Emilien


2 Answers

For Sphinx users, an abbreviation can be added using the :abbr: role. For example,

This :abbr:`SDP (Software Development Plan)` defines ...

results in the following HTML

<p>This <abbr title="Software Development Plan">SDP</abbr> defines …</p>
like image 131
Frelling Avatar answered Sep 25 '22 23:09

Frelling


I have solved it for now by adding this at the bottom of the document:

.. |HTMLabbr| raw:: html

  <abbr title="Hypertext Markup Language">HTML</abbr>

Then in the document I've used this "tag"/custom role like this:

This document is written in |HTMLabbr| and renders nicely in a modern browser.

For each abbreviation you would have to define a new custom role, I'm wondering if there is a way to have a "tag" that would take the value and the title as parameters instead of having to hard-code it like this.

like image 30
Emilien Avatar answered Sep 22 '22 23:09

Emilien