From 7bb7f8f57eb4ae1872ea9767b1cf032093041f5b Mon Sep 17 00:00:00 2001
From: gemmaro <gemmaro.dev@gmail.com>
Date: Sun, 2 Jul 2023 11:08:35 +0900
Subject: [PATCH] Allow comment end with attribute end.

---
 djot/attributes.lua  | 5 ++++-
 test/attributes.test | 9 ++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/djot/attributes.lua b/djot/attributes.lua
index 259cd65..ad6a62a 100644
--- a/djot/attributes.lua
+++ b/djot/attributes.lua
@@ -76,8 +76,11 @@ handlers[SCANNING] = function(self, pos)
 end
 
 handlers[SCANNING_COMMENT] = function(self, pos)
-  if sub(self.subject, pos, pos) == "%" then
+  local c = sub(self.subject, pos, pos)
+  if c == "%" then
     return SCANNING
+  elseif c == "}" then
+    return DONE
   else
     return SCANNING_COMMENT
   end
diff --git a/test/attributes.test b/test/attributes.test
index f84151c..b42f641 100644
--- a/test/attributes.test
+++ b/test/attributes.test
@@ -197,7 +197,8 @@ two
 ```
 
 Comments start at a `%` character
-(not in quotes) and end with another `%`.
+(not in quotes) and end with another `%` or
+the end of the attribute (`}`).
 These can be used to comment up an attribute
 list or without any real attributes.
 
@@ -207,6 +208,12 @@ foo{#ident % this is a comment % .class}
 <p><span class="class" id="ident">foo</span></p>
 ```
 
+```
+foo{#ident % this is a comment}
+.
+<p><span id="ident">foo</span></p>
+```
+
 In block-level comment, subsequent lines must
 be indented, as with attributes:
 
-- 
2.47.3

