items must not produce stray empty bullets.
+ input := ``
+
+ result := preProcessHTML(input)
+
+ if !strings.Contains(result, "| • x | ") {
+ t.Errorf("Expected a single non-empty bullet (• x | ), got: %s", result)
+ }
+}
+
+func TestPreProcessHTML_SentinelCollisionNeutralized(t *testing.T) {
+ // User content that literally contains the internal sentinel must not be able
+ // to inject a line break; the sentinel should be stripped from the input.
+ input := `literal ` + cellLineBreakSentinel + ` text
`
+
+ result := preProcessHTML(input)
+
+ if strings.Contains(result, cellLineBreakSentinel) {
+ t.Errorf("Expected pre-existing sentinel to be neutralized, got: %s", result)
+ }
+}
+
+func TestPreProcessHTML_MixedHeaderRowNotPromoted(t *testing.T) {
+ // A first row mixing and | is not a genuine header row and must not
+ // be lifted into .
+ input := ``
+
+ result := preProcessHTML(input)
+
+ if strings.Contains(result, "") {
+ t.Errorf("Expected a mixed th/td first row NOT to be promoted, got: %s", result)
+ }
+}
+
+// --- Phase 3 (TDD): regression locks for behavior that should already be correct ---
+
+func TestFlattenCellLists_OrderedListsRestartNumbering(t *testing.T) {
+ // Two separate ordered lists in one cell must each restart numbering at 1.
+ input := ``
+
+ result := preProcessHTML(input)
+
+ for _, want := range []string{"1. a", "2. b", "1. c", "2. d"} {
+ if !strings.Contains(result, want) {
+ t.Errorf("Expected %q in numbered output, got: %s", want, result)
+ }
+ }
+}
+
+func TestFlattenCellLists_OrderedEmptyItemAndStrayLi(t *testing.T) {
+ // Covers: an empty in an ordered list (skipped, numbering not consumed),
+ // and stray elements outside any recognized list (bulleted / dropped).
+ input := ``
+
+ result := preProcessHTML(input)
+
+ if !strings.Contains(result, "1. keep") {
+ t.Errorf("Expected ordered numbering to skip the empty item, got: %s", result)
+ }
+ if !strings.Contains(result, "• stray") {
+ t.Errorf("Expected stray to be bulleted, got: %s", result)
+ }
+ if strings.Contains(result, "| A |
|---|
| 1 | |