MCPcopy Create free account
hub / github.com/github/gh-aw / removeXMLCommentsFromLine

Function removeXMLCommentsFromLine

pkg/workflow/xml_comments.go:85–124  ·  view source on GitHub ↗

removeXMLCommentsFromLine removes XML comments from a single line Returns: processed line, was initially in comment, is now in comment

(line string, inXMLComment bool)

Source from the content-addressed store, hash-verified

83// removeXMLCommentsFromLine removes XML comments from a single line
84// Returns: processed line, was initially in comment, is now in comment
85func removeXMLCommentsFromLine(line string, inXMLComment bool) (string, bool, bool) {
86 result := line
87 wasInComment := inXMLComment
88
89 for {
90 if inXMLComment {
91 // We're in a multiline comment, look for closing tag
92 if closeIndex := strings.Index(result, "-->"); closeIndex != -1 {
93 // Found closing tag, remove everything up to and including it
94 result = result[closeIndex+3:]
95 inXMLComment = false
96 // Continue processing in case there are more comments on this line
97 } else {
98 // No closing tag found, entire line is part of the comment
99 return "", wasInComment, inXMLComment
100 }
101 } else {
102 // Not in a comment, look for opening tag
103 if openIndex := strings.Index(result, "<!--"); openIndex != -1 {
104 // Found opening tag
105 if closeIndex := strings.Index(result[openIndex:], "-->"); closeIndex != -1 {
106 // Complete comment on same line
107 actualCloseIndex := openIndex + closeIndex + 3
108 result = result[:openIndex] + result[actualCloseIndex:]
109 // Continue processing in case there are more comments on this line
110 } else {
111 // Start of multiline comment
112 result = result[:openIndex]
113 inXMLComment = true
114 break
115 }
116 } else {
117 // No opening tag found, done processing this line
118 break
119 }
120 }
121 }
122
123 return result, wasInComment, inXMLComment
124}
125
126// extractCodeBlockMarker extracts the marker string and language from a code block line
127// Returns marker string (e.g., "```", "~~~~") and language specifier

Callers 2

removeXMLCommentsFunction · 0.85

Calls

no outgoing calls

Tested by 1