here", true},
+ {"HTML in fenced code block", "```\n
hi
\n```", false},
+ {"HTML in indented code block", "
hi
", false},
+ {"HTML in inline code", "Use `
` for this", false},
+ {"HTML in prose AND code block", "
\n\n```\n
x
\n```", true},
+ {"angle bracket not HTML", "x < y", false},
+ {"hyphenated custom element", "Use
here", true},
+ {"namespaced XML tag", "The element", true},
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ got := containsHTMLOutsideCode(tt.in)
+ if got != tt.want {
+ t.Errorf("containsHTMLOutsideCode() = %v, want %v", got, tt.want)
+ }
+ })
+ }
+}
+
+func TestIsBlockElement(t *testing.T) {
+ blockLines := []string{
+ "# Header",
+ "## Header 2",
+ "- list item",
+ "* list item",
+ "+ list item",
+ "1. ordered",
+ "12. multi-digit ordered",
+ "> blockquote",
+ "| table row",
+ }
+ for _, line := range blockLines {
+ if !isBlockElement(line) {
+ t.Errorf("expected isBlockElement(%q) = true", line)
+ }
+ }
+
+ nonBlockLines := []string{
+ "just text",
+ "This starts a sentence.",
+ "2nd place finish",
+ }
+ for _, line := range nonBlockLines {
+ if isBlockElement(line) {
+ t.Errorf("expected isBlockElement(%q) = false", line)
+ }
+ }
+}
+
+func TestIsHorizontalRule(t *testing.T) {
+ rules := []string{"---", "***", "___", "- - -", "* * *", "----", "****"}
+ for _, r := range rules {
+ if !isHorizontalRule(r) {
+ t.Errorf("expected isHorizontalRule(%q) = true", r)
+ }
+ }
+
+ nonRules := []string{"--", "**", "-", "abc", "---x"}
+ for _, r := range nonRules {
+ if isHorizontalRule(r) {
+ t.Errorf("expected isHorizontalRule(%q) = false", r)
+ }
+ }
+}