TestRemoveXMLCommentsComplexNesting tests complex nesting scenarios
(t *testing.T)
| 911 | |
| 912 | // TestRemoveXMLCommentsComplexNesting tests complex nesting scenarios |
| 913 | func TestRemoveXMLCommentsComplexNesting(t *testing.T) { |
| 914 | tests := []struct { |
| 915 | name string |
| 916 | input string |
| 917 | expected string |
| 918 | }{ |
| 919 | { |
| 920 | name: "Code block, then comment, then code block", |
| 921 | input: "```\ncode1\n```\n<!-- comment -->\n```\ncode2\n```", |
| 922 | expected: "```\ncode1\n```\n\n```\ncode2\n```", |
| 923 | }, |
| 924 | { |
| 925 | name: "Comment, then code block, then comment", |
| 926 | input: "<!-- c1 -->\n```\ncode\n```\n<!-- c2 -->", |
| 927 | expected: "\n```\ncode\n```\n", |
| 928 | }, |
| 929 | { |
| 930 | name: "Interleaved comments and code blocks", |
| 931 | input: `Text |
| 932 | <!-- Start comment |
| 933 | Comment line 1 |
| 934 | Comment line 2 |
| 935 | End comment --> |
| 936 | ` + "```" + ` |
| 937 | Code block |
| 938 | ` + "```" + ` |
| 939 | <!-- Another comment --> |
| 940 | Final text`, |
| 941 | expected: `Text |
| 942 | |
| 943 | ` + "```" + ` |
| 944 | Code block |
| 945 | ` + "```" + ` |
| 946 | |
| 947 | Final text`, |
| 948 | }, |
| 949 | { |
| 950 | name: "Code block with comment-like content (not actual comments)", |
| 951 | input: `Text |
| 952 | ` + "```html" + ` |
| 953 | <div> |
| 954 | <!-- This looks like a comment but it's HTML in code --> |
| 955 | </div> |
| 956 | ` + "```" + ` |
| 957 | End`, |
| 958 | expected: `Text |
| 959 | ` + "```html" + ` |
| 960 | <div> |
| 961 | <!-- This looks like a comment but it's HTML in code --> |
| 962 | </div> |
| 963 | ` + "```" + ` |
| 964 | End`, |
| 965 | }, |
| 966 | } |
| 967 | |
| 968 | for _, tt := range tests { |
| 969 | t.Run(tt.name, func(t *testing.T) { |
| 970 | result := removeXMLComments(tt.input) |
nothing calls this directly
no test coverage detected