@@ -25,11 +25,14 @@ func TestStripFrontmatter(t *testing.T) {
2525 {"indented title is not the title" , "---\n config:\n title: nested\n ---\n diagram" , "diagram" , "" },
2626 {"crlf input" , "---\r \n title: t\r \n ---\r \n diagram" , "diagram" , "t" },
2727 {"multiline themeCSS config" , "---\n config:\n themeCSS: |\n rect { fill: red; }\n ---\n erDiagram" , "erDiagram" , "" },
28+ {"inline comment stripped from title" , "---\n title: hi # note\n ---\n diagram" , "diagram" , "hi" },
29+ {"hash kept inside quoted title" , "---\n title: \" a # b\" \n ---\n diagram" , "diagram" , "a # b" },
30+ {"no space after colon is not a mapping" , "---\n title:xyz\n ---\n diagram" , "diagram" , "" },
2831 }
2932 for _ , c := range cases {
3033 t .Run (c .name , func (t * testing.T ) {
3134 rest , title := StripFrontmatter (c .in )
32- if rest != c .wantRest && normalize ( rest ) != c . wantRest {
35+ if rest != c .wantRest {
3336 t .Errorf ("rest = %q, want %q" , rest , c .wantRest )
3437 }
3538 if title != c .wantTitle {
@@ -38,14 +41,3 @@ func TestStripFrontmatter(t *testing.T) {
3841 })
3942 }
4043}
41-
42- // normalize strips \r so CRLF inputs compare against \n expectations.
43- func normalize (s string ) string {
44- out := make ([]rune , 0 , len (s ))
45- for _ , r := range s {
46- if r != '\r' {
47- out = append (out , r )
48- }
49- }
50- return string (out )
51- }
0 commit comments