From a0583ef8270d025b3e86ef521b35f7397cf7215b Mon Sep 17 00:00:00 2001
From: Noah Hellman <noah@hllmn.net>
Date: Tue, 24 Jan 2023 16:25:57 +0100
Subject: [PATCH] block: prio roman numerals over alpha when ambig.

Fix for https://github.com/jgm/djot.js/issues/38
---
 djot/block.lua  |  4 ++--
 test/lists.test | 16 ++++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/djot/block.lua b/djot/block.lua
index eaa7a6a..72e3bc5 100644
--- a/djot/block.lua
+++ b/djot/block.lua
@@ -27,9 +27,9 @@ 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
@@ -465,6 +465,22 @@ 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
-- 
2.47.3

