Skip to content

Commit 84f75d5

Browse files
authored
Merge pull request #12 from breml/fix-wrong-comment-marker
Fix wrong comment marker
2 parents 771314b + bdfe4d2 commit 84f75d5

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ast/ast_helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
// * line of comment
1313
// * line without any quotes
1414
// * line(s) with quoted strings, which are kept together to form a single "line of configuration"
15-
var linesRe = regexp.MustCompile(`(\n|\s*//[^\n]*\n|[^'"\n]*\n|([^"'\n]*("(\\"|[^"])*"|'(\\'|[^'])*')[^"'\n]*)*\n)`)
15+
var linesRe = regexp.MustCompile(`(\n|\s*#[^\n]*\n|[^'"\n]*\n|([^"'\n]*("(\\"|[^"])*"|'(\\'|[^'])*')[^"'\n]*)*\n)`)
1616

1717
func prefix(in string, emptyNewline bool) string {
1818
if len(in) == 0 {

ast/ast_helper_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ func TestPrefix(t *testing.T) {
3030
},
3131
{
3232
name: "simple attribute with comment",
33-
input: `// comment
33+
input: `# comment
3434
value => 3.1415
3535
`,
3636

3737
want: `
38-
// comment
38+
# comment
3939
value => 3.1415
4040
`,
4141
},
4242
{
4343
name: "block",
4444
input: `add_field {
45-
// comment
45+
# comment
4646
value => 3.1415
4747
}
4848
@@ -51,7 +51,7 @@ add_tag => [ "foobar" ]
5151

5252
want: `
5353
add_field {
54-
// comment
54+
# comment
5555
value => 3.1415
5656
}
5757
@@ -90,12 +90,12 @@ lines'
9090
},
9191
{
9292
name: "comment with double and single quote",
93-
input: `// comment with " and '
93+
input: `# comment with " and '
9494
othervalue => 3.1415
9595
`,
9696

9797
want: `
98-
// comment with " and '
98+
# comment with " and '
9999
othervalue => 3.1415
100100
`,
101101
},

0 commit comments

Comments
 (0)