From 5d8f8cdca51c3fdcfe6657adcd5b7d2872571940 Mon Sep 17 00:00:00 2001 From: pfg Date: Sun, 3 Oct 2021 16:32:30 -0400 Subject: [PATCH] fix assuming multiline string tokens end with '\n' --- doc/docgen.zig | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/docgen.zig b/doc/docgen.zig index 0f6aacb465..139a58565e 100644 --- a/doc/docgen.zig +++ b/doc/docgen.zig @@ -990,9 +990,15 @@ fn tokenizeAndPrintRaw( }, .multiline_string_literal_line => { - try out.writeAll(""); - try writeEscaped(out, src[token.loc.start .. token.loc.end - 1]); - try out.writeAll("" ++ end_line ++ "\n" ++ start_line); + if (src[token.loc.end - 1] == '\n') { + try out.writeAll(""); + try writeEscaped(out, src[token.loc.start .. token.loc.end - 1]); + try out.writeAll("" ++ end_line ++ "\n" ++ start_line); + } else { + try out.writeAll(""); + try writeEscaped(out, src[token.loc.start..token.loc.end]); + try out.writeAll(""); + } }, .builtin => {