Skip to content

mjbear/markdown-footnote-sorter

 
 

Repository files navigation

markdown-footnote-sorter

A script to sort footnotes in a markdown file.

Reads a Markdown file passed as the first argument and sorts footnotes. The reference links will be numbered in the order they appear in the text and placed at the bottom of the file.

Based on https://github.com/derdennis/sort-markdown-footnotes

Inspired by http://www.leancrew.com/all-this/2012/09/tidying-markdown-reference-links/

fnsorter.mp4

How to use?

  1. You can use the container image provided:

    docker run --rm -v $(pwd):/work ghcr.io/hellt/markdown-footnote-sorter path/to/doc.md
  2. Or download the script and put it in your $PATH:

    curl -sL \
    https://raw.githubusercontent.com/hellt/markdown-footnote-sorter/main/fnsort.py\
      > ~/.local/bin/fnsort.py
    
    fnsort.py path/to/doc.md
  3. Or from the GitHub UI, run the container in a ✨Codespace:

    • From this project's main page, click Code, then Codespace.
    • Choose Create codespace on <branch_name>

    This creates a codespace with the default resources (currently 2 CPU, 8 GB RAM, 32 GB Storage).

    • 🚀 Run fnsort on your markdown file:
    /app/fnsort.py path/to/doc.md

Important

Keep in mind there are monthly limits measured in core hours and to stop your codespace 🛑 when you're not using it to conserve your monthly core hours allowance.

Command Line Arguments

--adjacent

Adjacent inline references that are not separated by other characters become problematic (by default). This option adds spacing between those inline references so they are properly identified during sorting.

fnsort.py path/to/doc.md --adjacent

--keepnames

Retain or keep inline reference and footnote names. This prevents the default behavior of replacing the names with numbers. Footnotes at the end of the markdown are still sorted.

fnsort.py path/to/doc.md --keepnames

Contributing

For information about contributing to this project, see the contributing guidelines.

About

A script to sort footnotes in a markdown file

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • Python 85.4%
  • Makefile 13.6%
  • Dockerfile 1.0%