{"id":31578376,"url":"https://github.com/dhanushka2001/citeorder","last_synced_at":"2026-01-16T09:31:34.074Z","repository":{"id":316323502,"uuid":"1062898634","full_name":"dhanushka2001/citeorder","owner":"dhanushka2001","description":"Simple command-line tool to relabel Footnotes in Markdown files in numerical order. Program and integration testing written in C. Builds for Windows, macOS, and Linux.","archived":false,"fork":false,"pushed_at":"2026-01-13T10:05:23.000Z","size":126,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-13T11:55:34.639Z","etag":null,"topics":["c","citations","cli","command-line","command-line-tool","footnotes","integration-testing","markdown"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhanushka2001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T22:18:32.000Z","updated_at":"2026-01-13T10:04:54.000Z","dependencies_parsed_at":"2025-09-25T22:00:25.131Z","dependency_job_id":null,"html_url":"https://github.com/dhanushka2001/citeorder","commit_stats":null,"previous_names":["dhanushka2001/citeorder"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/dhanushka2001/citeorder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhanushka2001%2Fciteorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhanushka2001%2Fciteorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhanushka2001%2Fciteorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhanushka2001%2Fciteorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhanushka2001","download_url":"https://codeload.github.com/dhanushka2001/citeorder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhanushka2001%2Fciteorder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","citations","cli","command-line","command-line-tool","footnotes","integration-testing","markdown"],"created_at":"2025-10-05T19:57:15.085Z","updated_at":"2026-01-16T09:31:34.062Z","avatar_url":"https://github.com/dhanushka2001.png","language":"C","readme":"\u003cimg width=\"640\" height=\"320\" alt=\"citeorder-logo-light\" src=\"https://github.com/user-attachments/assets/21bdb71e-fbe1-4c4b-8f8d-5cd2d4f1fca7\" /\u003e\n\n# citeorder\n[![Build and Test](https://github.com/dhanushka2001/citeorder/actions/workflows/main.yml/badge.svg)](https://github.com/dhanushka2001/citeorder/actions/workflows/main.yml)\n[![GitHub Release](https://img.shields.io/github/v/release/dhanushka2001/citeorder)](https://github.com/dhanushka2001/citeorder/releases)\n[![GitHub License](https://img.shields.io/github/license/dhanushka2001/citeorder)](https://github.com/dhanushka2001/citeorder/blob/main/LICENSE)\n[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/dhanushka2001/citeorder)](https://github.com/dhanushka2001/citeorder/commits/main/)\n[![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/dhanushka2001/citeorder/total)](https://github.com/dhanushka2001/citeorder/releases)\n[![GitHub Repo stars](https://img.shields.io/github/stars/dhanushka2001/citeorder)](https://github.com/dhanushka2001/citeorder/stargazers)\n\n[![Windows](https://img.shields.io/badge/Windows-0078D6?style=plastic\u0026logo=windows\u0026logoColor=white)](https://github.com/dhanushka2001/citeorder/releases)\n[![macOS](https://img.shields.io/badge/macOS-000000?style=plastic\u0026logo=macos\u0026logoColor=F0F0F0)](https://github.com/dhanushka2001/citeorder/releases)\n[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?style=plastic\u0026logo=ubuntu\u0026logoColor=white)](https://github.com/dhanushka2001/citeorder/releases)\n[![Arch Linux](https://img.shields.io/badge/Arch_Linux-1793D1?style=plastic\u0026logo=arch-linux\u0026logoColor=white)](https://github.com/dhanushka2001/citeorder/releases)\n\n![C](https://img.shields.io/badge/C-%2300599C.svg?style=plastic\u0026logo=c\u0026logoColor=white)\n![Markdown](https://img.shields.io/badge/Markdown-%23000000.svg?style=plastic\u0026logo=markdown\u0026logoColor=white)\n\n\u003c!--\n![C](https://img.shields.io/badge/c-%2300599C.svg?style=for-the-badge\u0026logo=c\u0026logoColor=white)\n![Markdown](https://img.shields.io/badge/markdown-%23000000.svg?style=for-the-badge\u0026logo=markdown\u0026logoColor=white)\n--\u003e\n\nSimple command-line tool to correctly reorder Footnotes in Markdown files.\n\n## Motivation\n\nMarkdown processors that support footnotes (e.g. [GitHub’s Markdown engine](https://github.com/github/cmark-gfm), which implements the [GitHub Flavored Markdown](https://github.github.com/gfm) spec) automatically reorder footnotes when converting ``.md`` files to HTML. However, ``citeorder`` fixes the ordering in the ``.md`` file itself, making it neater and easier to manage lots of footnotes. Especially useful when needing to add new footnotes in the middle of a long ``.md`` file and not having to spend ages reordering every in-text and full-entry footnote manually (🥲).\n\nIn-text footnotes (``\"Alice here\",[^1]``) and full-entry footnotes (``[^1]: Alice``) are a many-to-one relationship. ``citeorder`` assumes the connections are correct, and relabels them according to the order in which the **in-text footnotes** appear.\n\n## How to use\n\n1. Download the precompiled executable from the latest [release](https://github.com/dhanushka2001/citeorder/releases).\n\n   Installation via Homebrew (macOS/Ubuntu):\n\n   ```bash\n   brew install dhanushka2001/citeorder/citeorder\n   ```\n\n   Installation via the [AUR](https://aur.archlinux.org/packages/citeorder) (Arch):\n   \n   ```bash\n   yay -S citeorder\n   ```\n\n   \u003cdetails\u003e\u003csummary\u003eOr clone the repo and compile source code\u003c/summary\u003e\n\n   If you want to compile the source code yourself, clone the repo and compile ``citeorder.c``:\n\n   ```console\n   git clone https://github.com/dhanushka2001/citeorder\n   ```\n   \n   ```console\n   gcc -Wall citeorder.c -o citeorder\n   ```\n\n   \u003c/details\u003e\n\n2. To run, simply enter into the terminal:\n\n   ```console\n   citeorder input.md\n   ```\n\n   where ``input.md`` is the Markdown file whose Footnotes you want reordered. ``citeorder`` will keep the original file as is and output the changes to a new file, ``input-fixed.md``.\n\n   To allow relaxed quote handling, do:\n\n   ```console\n   citeorder -q input.md\n   ```\n\n   For more info and options, run:\n\n   ```console\n   citeorder -h\n   ```\n\n## Example\n\n``example.md``:\n\n```md\n\"Alice says hi\".[^1]\n\n[^1]: Alice\n\n\"Bob is here\".[^7] \"I'm Charlie\",[^4] \"Daniel!\",[^5] here.\n\n[^4]: Charlie\n[^3]: Gary\n[^5]: Daniel\n[^7]: Bob\n\nIs \"Ethan\"[^8] here?\n\n[^8]: Ethan\n\n\"Bob and Charlie here again\"[^7][^4]\n\n[^6]: Fred\n```\n\nRunning:\n\n```console\nciteorder example.md\n```\n\nwill produce ``example-fixed.md``:\n\n```md\n\"Alice says hi\".[^1]\n\n[^1]: Alice\n\n\"Bob is here\".[^2] \"I'm Charlie\",[^3] \"Daniel!\",[^4] here.\n\n[^2]: Bob\n[^3]: Charlie\n[^4]: Daniel\n[^6]: Gary\n\nIs \"Ethan\"[^5] here?\n\n[^5]: Ethan\n\n\"Bob and Charlie here again\"[^2][^3]\n\n[^7]: Fred\n```\n\n## Cases handled\n\n* No changes needed.\n* Stacked in-text footnotes, e.g. ``\"hello\",[^3][^1][^5]`` → ``\"hello\",[^1][^2][^3]``.\n* Single punctuation (or none) after end quote, e.g. ``\"A\"[^3] \"B\",[^2] \"C\".[^6] \"D\"![^5]`` → ``\"A\"[^1] \"B\",[^2] \"C\".[^3] \"D\"![^4]``.\n* Improper quote, e.g. ``\"hello[^1]``, ``\"hello\",,[^1]``, ``hello\"[^1]``, ``\"hello\" [^1]`` produces an error message like: ``ERROR: in-text citation [^1] not properly quoted (line 5)``. Can ignore this error with the ``-r``/``--relaxed-quotes`` flag.\n* Full-entry footnotes with no matching in-text footnotes simply get bubbled to the end of the ordering.\n* In-text footnotes with no matching full-entry footnote produce an error message like: ``ERROR: in-text citation [^2] without full-entry (line 3)``.\n* Duplicate full-entry footnotes, e.g.\n\n  ```md\n  [^4]: Alice\n  [^4]: Bob\n  ```\n  \n  produces an error message like: ``ERROR: duplicate [^4] full-entry citations (line 7 and 8)``.\n* Footnotes inside inline code (``\"A\"[^1]``) and fenced code blocks:\n\n  ```md\n  \"A\"[^1]\n\n  [^1]: A\n  [^2]: B\n  ```\n\n  are ignored.\n* Footnote labels with letters/symbols are supported, and will be relabeled accordingly, e.g. ``\"A\"[^6b]`` → ``\"A\"[^1]``.\n* Spaces in the in-text or full-entry footnotes. Spaces outside the label for in-text footnotes, e.g. ``\"A\"[^  Alice ]`` are accepted by Markdown processors, and ``citeorder`` will convert that to ``\"A\"[^1]``. However, for full-entry footnotes, e.g. ``[^ 4b  ]: Alice``, it is not accepted, and in ``citeorder`` it will produce an error message like: ``ERROR: [^ 4b  ] full-entry citation contains a space (line 3)``. For both in-text and full-entry footnotes, spaces **in** the label itself, e.g. ``\"A\"[^4 b]``, ``[^4 b]: Alice``, are not accepted, and in ``citeorder`` you will get an error message.\n* In-text or full-entry footnote missing a label, e.g. ``\"A\"[^]``, will produce an error message like: ``ERROR: in-text citation [^] missing label (line 7)``.\n* Multiline quote: \n\n  ```md\n  \"T\"[^4]\n  \n  \"This quote takes\n  \n  up multiple lines\n  \n  but is still valid\",[^3]\n  \n  \"H\",[^6]\n  \n  [^4]: T\n  [^6]: H\n  [^3]: Multiline quote\n  ```\n\n  becomes:\n\n  ```md\n  \"T\"[^1]\n  \n  \"This quote takes\n  \n  up multiple lines\n  \n  but is still valid\",[^2]\n  \n  \"H\",[^3]\n  \n  [^1]: T\n  [^2]: Multiline quote\n  [^3]: H\n  ```\n* Duplicate full-entry footnotes, e.g.\n\n  ```md\n  \"A\"[^dupe], \"B\"[^dupe]\n\n  [^dupe]: A\n  [^dupe]: B\n\n  \"C\"[^dupe]\n\n  [^dupe]: C\n\n  \"D\"[^1]\n\n  [^1]: D\n  ```\n\n  can be auto-incremented using the ``-d``/``--relaxed-duplicates`` flag (must be only ONE duplicate footnote label, and must have an equal number of full-entry and in-text duplicates):\n\n  ```md\n  \"A\"[^1], \"B\"[^2]\n\n  [^1]: A\n  [^2]: B\n\n  \"C\"[^3]\n\n  [^3]: C\n\n  \"D\"[^4]\n\n  [^4]: D\n  ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhanushka2001%2Fciteorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhanushka2001%2Fciteorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhanushka2001%2Fciteorder/lists"}