From 5069ef760e7bb8d6a4fb687dee3b6be8352ccc5d Mon Sep 17 00:00:00 2001 From: Runji Wang Date: Wed, 25 Oct 2023 18:04:04 +0800 Subject: [PATCH] fix trim spaces bug in docslt Signed-off-by: Runji Wang --- src/risedevtool/src/bin/risedev-docslt.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/risedevtool/src/bin/risedev-docslt.rs b/src/risedevtool/src/bin/risedev-docslt.rs index 6a76ed1035959..0f5307422f3d6 100644 --- a/src/risedevtool/src/bin/risedev-docslt.rs +++ b/src/risedevtool/src/bin/risedev-docslt.rs @@ -53,11 +53,12 @@ fn extract_slt(filepath: &Path) -> Vec { if !(line.starts_with("///") || line.starts_with("//!")) { panic!("expect /// or //! at {}:{}", filepath.display(), i + 1); } - line = line[3..].trim(); - if line == "```" { + line = &line[3..]; + if line.trim() == "```" { break; } - content += line; + // strip one leading space + content += line.strip_prefix(' ').unwrap_or(line); content += "\n"; } blocks.push(SltBlock {