mirror of
https://github.com/maaslalani/slides.git
synced 2026-01-08 22:07:59 -05:00
22 lines
545 B
Go
22 lines
545 B
Go
package code
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
const comment = "///"
|
|
|
|
var commentRegexp = regexp.MustCompile("(?m)[\r\n]+^" + comment + ".*$")
|
|
|
|
// HideComments removes all comments from the given content.
|
|
func HideComments(content string) string {
|
|
return commentRegexp.ReplaceAllString(content, "")
|
|
}
|
|
|
|
// RemoveComments strips all the comments from the given content.
|
|
// This is useful for when we want to actually use the content of the comments.
|
|
func RemoveComments(content string) string {
|
|
return strings.ReplaceAll(content, comment, "")
|
|
}
|