Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding non-case-sensitive alphabetical sorting incl testing #5

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion _extensions/acronyms/sort_acronyms.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@
local sorting_strategies = {}


-- Sort acronyms by their shortname, in alphabetical order.
-- Sort acronyms by their shortname, in case-sensitive alphabetical order.
sorting_strategies["alphabetical"] = function(acronym1, acronym2)
-- TODO: check that this works with UTF-8 characters
return acronym1.shortname < acronym2.shortname
end

-- Sort acronyms by their shortname, in non-case-sensitive alphabetical order.
sorting_strategies["alphabetical_ignore_case"] = function(acronym1, acronym2)
return acronym1.shortname:upper() < acronym2.shortname:upper()
end

-- Sort acronyms by their definition order (first to last).
sorting_strategies["initial"] = function(acronym1, acronym2)
Expand Down
3 changes: 3 additions & 0 deletions tests/20-sorting-alphabetical-ignore-case/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This test shows the "alphabetical_ignore_case" sorting option.

The List Of Acronyms is sorted based on their key, in a non-case-sensitive alphabetical order.
20 changes: 20 additions & 0 deletions tests/20-sorting-alphabetical-ignore-case/expected.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# List Of Acronyms {#acronyms_HEADER_LOA .loa}

[aA]{#acronyms_aA}
: alphabetically

[H]{#acronyms_H}
: handle

[iQt]{#acronyms_iQt}
: inside-Quarto

[Qt]{#acronyms_Qt}
: Quarto

# Introduction {#intro}

This [Quarto (Qt)](#acronyms_Qt) extension adds the ability to automatically [handle (H)](#acronyms_H)
[inside-Quarto (iQt)](#acronyms_iQt) acronyms.

Would love to be able to sort [alphabetically (aA)](#acronyms_aA), independent of letter size.
23 changes: 23 additions & 0 deletions tests/20-sorting-alphabetical-ignore-case/input.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
output:
acronymsdown::md_format
acronyms:
sorting: alphabetical_ignore_case
include_unused: false
keys:
- shortname: Qt
longname: Quarto
- shortname: iQt
longname: inside-Quarto
- shortname: aA
longname: alphabetically
- shortname: H
longname: handle
---

# Introduction {#intro}

This \acr{Qt} extension adds the ability to automatically \acr{handle}
\acr{iQt} acronyms.

Would love to be able to sort \acr{aA}, independent of letter size.