summaryrefslogtreecommitdiffstats
path: root/cnmfmt
diff options
context:
space:
mode:
Diffstat (limited to 'cnmfmt')
-rw-r--r--cnmfmt/cnmfmt.go2
-rw-r--r--cnmfmt/cnmfmt_test.go15
2 files changed, 14 insertions, 3 deletions
diff --git a/cnmfmt/cnmfmt.go b/cnmfmt/cnmfmt.go
index 1e5b6ee..3e38978 100644
--- a/cnmfmt/cnmfmt.go
+++ b/cnmfmt/cnmfmt.go
@@ -195,7 +195,7 @@ func (t Text) WriteIndent(w io.Writer, n int) error {
if span.Text != "" {
pad = " "
}
- line = append(line, "@@", cnm.Escape(span.Format.Link), pad)
+ line = append(line, "@@", cnm.EscapeAll(span.Format.Link), pad)
}
}
}
diff --git a/cnmfmt/cnmfmt_test.go b/cnmfmt/cnmfmt_test.go
index 5d50b18..2ad92cb 100644
--- a/cnmfmt/cnmfmt_test.go
+++ b/cnmfmt/cnmfmt_test.go
@@ -127,6 +127,9 @@ var parseTests = map[string]Text{
"@@foo ": Text{[]Span{
Span{Format{Link: "foo"}, ""},
}},
+ "@@foo\\ bar baz quux@@": Text{[]Span{
+ Span{Format{Link: "foo bar"}, "baz quux"},
+ }},
"@@foo\\": Text{[]Span{
Span{Format{Link: "foo\\"}, ""},
}},
@@ -213,9 +216,9 @@ func textEqual(a, b Text) bool {
}
var escapeTests = map[string]string{
- "\n\r\t\v\x00": "\\n\\r\\t\v\\x00",
+ "\n\r\t\v\x00": "\\n\\r\\t\v\\x00",
"@@!!##\"\"//\"\"__``**%%^^&&++==\x01\x01\\": "\\@\\@!!##\\\"\\\"//\\\"\\\"\\_\\_\\`\\`\\*\\*%%^^&&++==\x01\x01\\\\",
- `foo\@\@bar`: `foo\\\@\\\@bar`,
+ `foo\@\@bar`: `foo\\\@\\\@bar`,
}
func TestEscape(t *testing.T) {
@@ -269,6 +272,10 @@ var parseTextTests = map[string]TextFmtContents{
Text{[]Span{Span{Format{Emphasized: true}, "foo"}}},
Text{[]Span{Span{Format{}, "bar"}}},
}},
+
+ "@@foo\\ bar baz quux@@": TextFmtContents{[]Text{
+ Text{[]Span{Span{Format{Link: "foo bar"}, "baz quux"}}},
+ }},
}
func TestParseTextFmt(t *testing.T) {
@@ -335,6 +342,10 @@ var writeTests = map[string]TextFmtContents{
}},
}},
+ "@@foo\\ bar baz quux\n": TextFmtContents{[]Text{
+ Text{[]Span{Span{Format{Link: "foo bar"}, "baz quux"}}},
+ }},
+
"foo**bar``baz**quux\n\n" +
"\\ \"\"qwe\\ \"\"__\\ asd \\ __``zxc``**\\ \n\n" +
"__@@http://example.com/__/ exa__mple@@ @@href text@@__ test\n": TextFmtContents{[]Text{