download patch
commit a0583ef8270d025b3e86ef521b35f7397cf7215b
Author: Noah Hellman <noah@hllmn.net>
Date: Tue Jan 24 16:25:57 2023 +0100
block: prio roman numerals over alpha when ambig.
Fix for https://github.com/jgm/djot.js/issues/38
diff --git a/djot/block.lua b/djot/block.lua
index eaa7a6a..72e3bc5 100644
--- a/djot/block.lua
+++ b/djot/block.lua
local function get_list_styles(marker)
return {(marker:gsub("%d+","1"))}
-- in ambiguous cases we return two values
elseif find(marker, "^[(]?[ivxlcdm][).]") then
- return {(marker:gsub("%a+", "a")), (marker:gsub("%a+", "i"))}
+ return {(marker:gsub("%a+", "i")), (marker:gsub("%a+", "a"))}
elseif find(marker, "^[(]?[IVXLCDM][).]") then
- return {(marker:gsub("%a+", "A")), (marker:gsub("%a+", "I"))}
+ return {(marker:gsub("%a+", "I")), (marker:gsub("%a+", "A"))}
elseif find(marker, "^[(]?%l[).]") then
return {(marker:gsub("%l", "a"))}
elseif find(marker, "^[(]?%u[).]") then
diff --git a/test/lists.test b/test/lists.test
index 9094e0c..cac8b7d 100644
--- a/test/lists.test
+++ b/test/lists.test
b
</ol>
```
+When ambiguous, prioritize roman numerals.
+
+```
+i. a
+i. b
+.
+<ol type="i">
+<li>
+a
+</li>
+<li>
+b
+</li>
+</ol>
+```
+
```
I. a
II. b