- Shell 100%
| COPYING | Add main files | |
| geminiReCite.sh | Uuuh... Ok. A negated set automatically focus characters, no need to escape them. | |
| README.md | First (real) commit | |
GeminiReCite — Automate citations' numbering of GemText files in a footnote-style
Bash script for automatic citations' numbering of Gemtext files, especially useful when adding new citations in-between others.
GemText format
The GemText specification states that any link must be on its own line, starting with the => sequence.
By design, that is easily matched, and parsed through the ^=> regexp.
Other than that, there's no official format for citations.
Footnote-style
Considering the diversity of content to be linked, the more elegant way to cite anything is IMHO the numbered footnote-style. That is, a bracketed inline number, matched with a link in the end-bibliography section such as:
The GemText specification[1] states than any link must be on its own line, starting with the `=>` sequence.
=> gemini://gemini.circumlunar.space/docs/gemtext.gmi [1] A quick introduction to "gemtext" markup
Usecase
The main usecase for this script is for those reviewing their writings, and inserting new citations inside the text. Doing so would require one to renumber each following citation which, in my case, is a pain to do manually.
This script automatically renumber the bracketed references in a file, both in the text and the bibliography section. It specifically matches my own way of formatting Gemini files, and assumes:
- Each link to be referenced in the text once. No less, and no more.
- The bibliography to be separated from the main text.
- The links in the bibliography to be ordered as they appears in the text.
Only the first condition is checked, at launch, the second one could be implemented further down the way if requested, while the last one seems like an impossible task.
Dependencies
Each step of the script is commented and quite simple, but feel free to request for clarifications. The whole script is built upon:
sedfor modifications.catandgrepfor accessory checks.