diff --git a/pkg/generator/latex.go b/pkg/generator/latex.go index 180851f..e3222d2 100644 --- a/pkg/generator/latex.go +++ b/pkg/generator/latex.go @@ -15,9 +15,9 @@ func replaceUnescapedChar(str string) string { "$", "{\\$}", "{", "{\\{}", "}", "{\\}}", - "\\", "\\textbackslash", - "^", "\\textasciicircum", - "~", "\\textasciitilde", + "\\", "{\\textbackslash}", + "^", "{\\textasciicircum}", + "~", "{\\textasciitilde}", ) return s.Replace(str) diff --git a/pkg/generator/latex_test.go b/pkg/generator/latex_test.go index 3025f3c..955f1b0 100644 --- a/pkg/generator/latex_test.go +++ b/pkg/generator/latex_test.go @@ -7,7 +7,7 @@ import ( func TestReplaceUnescapeChar(t *testing.T) { test := `#$%&\_{}^~` actual := replaceUnescapedChar(test) - expected := `{\#}{\$}{\%}{\&}\textbackslash{\_}{\{}{\}}\textasciicircum\textasciitilde` + expected := `{\#}{\$}{\%}{\&}{\textbackslash}{\_}{\{}{\}}{\textasciicircum}{\textasciitilde}` if actual != expected { t.Errorf("failed when replacing escape character, got: %s, expected: %s", actual, expected) }