Repository: kivikakk/comrak (Rust)

Issue:
Parsing for HTML block of kind 4 expects only ASCII uppercase letters
When implementing the tests in #656, I noticed the following issue.

The [CommonMark spec about HTML block](https://spec.commonmark.org/0.31.2/#html-blocks) of kind 4 says:

> 4. **Start condition**: line begins with the string `<!` followed by an ASCII letter.
> **End condition**: line contains the character `>`.

When looking at the following input, both lines should create a HTML block according to the spec:
```
<!A>
<!a>
```

I tried it in the [commonmark.js dingus](https://spec.commonmark.org/dingus/?text=%3C!A%3E%0A%3C!a%3E) and the AST output was:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document xmlns="http://commonmark.org/xml/1.0">
  <html_block>&lt;!A&gt;</html_block>
  <html_block>&lt;!a&gt;</html_block>
</document>
```

But when I tried it in the [CommonMark/GFM/GLFM dingus](https://gitlab-org.gitlab.io/ruby/gems/gitlab-glfm-markdown/?text=%3C!A%3E%0A%3C!a%3E#result-ast) (the only dingus online that uses comrak - even though it uses v0.43, I tested this locally with the most up-to-date `main` branch and it behaved the same), the AST output was:
```
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE document SYSTEM "CommonMark.dtd">
<document sourcepos="1:1-2:4" xmlns="http://commonmark.org/xml/1.0">
  <html_block sourcepos="1:1-0:0" xml:space="preserve">&lt;!A&gt;
</html_block>
  <paragraph sourcepos="2:1-2:4">
    <text sourcepos="2:1-2:4" xml:space="preserve">&lt;!a&gt;</text>
  </paragraph>
</document>
```

I think the culprit is the [line 180 in scanners.rs](https://github.com/kivikakk/comrak/blob/ad4bc940d3b6452759a3be958cf64a9831d74e7b/src/scanners.re#L180) that expects the ASCII letter to be uppercase:
```
'<!' [A-Z] { return Some(4); }
``` 


Discussion:
Nice catch! This error has existed since [the very first version of Comrak](https://github.com/kivikakk/comrak/commit/9b6c5bf64cdaf5b4d91d02eb4dd38bfd885f39f9):

https://github.com/kivikakk/comrak/blob/9b6c5bf64cdaf5b4d91d02eb4dd38bfd885f39f9/src/scanners.rs#L82

Will fix — thank you!



Patch:
diff --git a/src/scanners.re b/src/scanners.re
index 861c7c3e..108a7a21 100644
--- a/src/scanners.re
+++ b/src/scanners.re
@@ -177,7 +177,7 @@ pub fn html_block_start(s: &str) -> Option<usize> {
     [<] ('script'|'pre'|'textarea'|'style') (spacechar | [>]) { return Some(1); }
     '<!--' { return Some(2); }
     '<?' { return Some(3); }
-    '<!' [A-Z] { return Some(4); }
+    '<!' [A-Za-z] { return Some(4); }
     '<![CDATA[' { return Some(5); }
     [<] [/]? blocktagname (spacechar | [/]? [>])  { return Some(6); }
     * { return None; }
diff --git a/src/scanners.rs b/src/scanners.rs
index 13d8eab3..9bc40858 100644
--- a/src/scanners.rs
+++ b/src/scanners.rs
@@ -1,4 +1,4 @@
-/* Generated by re2rust 4.3 */
+/* Generated by re2rust 4.1 */
 
 pub fn atx_heading_start(s: &str) -> Option<usize> {
     let mut cursor = 0;
@@ -6611,7 +6611,7 @@ pub fn html_block_start(s: &str) -> Option<usize> {
                             yystate = 23;
                             continue 'yyl;
                         }
-                        0x41..=0x5A => {
+                        0x41..=0x5A | 0x61..=0x7A => {
                             cursor += 1;
                             yystate = 24;
                             continue 'yyl;


Test patch:
diff --git a/src/tests/html.rs b/src/tests/html.rs
index 6a7d91de..4fca765d 100644
--- a/src/tests/html.rs
+++ b/src/tests/html.rs
@@ -136,6 +136,19 @@ fn sourcepos_kind_1() {
         ])
     );
 
+    assert_ast_match!(
+        [],
+        "<SCRIPT>A html\n\n**block** </Script>\n\n**parsed**",
+        (document (1:1-5:10) [
+            (html_block (1:1-3:19) "<SCRIPT>A html\n\n**block** </Script>\n")
+            (paragraph (5:1-5:10) [
+                (strong (5:1-5:10) [
+                    (text (5:3-5:8) "parsed")
+                ])
+            ])
+        ])
+    );
+
     assert_ast_match!(
         [],
         "<style>A html block</style>",
@@ -307,15 +320,13 @@ fn sourcepos_kind_3() {
 
 #[test]
 fn sourcepos_kind_4() {
-    // Should produce HTML block according to CommonMark spec even with lowercase ASCII letter, but produces paragraph with text instead.
-    // See: https://github.com/kivikakk/comrak/issues/655
-    // assert_ast_match!(
-    //     [],
-    //     "<!a>",
-    //     (document (1:1-1:4) [
-    //         (html_block (1:1-1:4) "<!a>\n")
-    //     ])
-    // );
+    assert_ast_match!(
+        [],
+        "<!a>",
+        (document (1:1-1:4) [
+            (html_block (1:1-1:4) "<!a>\n")
+        ])
+    );
 
     assert_ast_match!(
         [],