Skip to content

Commit

Permalink
fix markdown doc test code hiding to match librustdoc (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterD1524 authored Feb 26, 2024
1 parent f26e91b commit e8d7458
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion content/tokio/topics/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ be used as a mock:
# line.clear();
# }
# }

#
#[tokio::test]
async fn client_handler_replies_politely() {
let reader = tokio_test::io::Builder::new()
Expand Down
14 changes: 13 additions & 1 deletion lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,19 @@ const remarkCodeRemoveSomeLines = () => {
if (node.lang && langs.includes(node.lang)) {
node.value = node.value
.split("\n")
.filter((line) => !line.startsWith("# "))
.map((line) => {
let trimmed = line.trim();
if (trimmed.startsWith("##")) {
return line.replace("##", "#");
} else if (trimmed.startsWith("# ")) {
return null;
} else if (trimmed === "#") {
return null;
} else {
return line;
}
})
.filter((line) => line !== null)
.join("\n");
}
});
Expand Down

0 comments on commit e8d7458

Please sign in to comment.