Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ private static String postProcessPandocOutput(String output) {

// Remove unnecessary backslash escapes that pandoc adds for markdown
// These characters don't need escaping in Python docstrings
// Handles: [ ] ' { } ( ) < > ` @ _ * | ! ~ $
output = output.replaceAll("\\\\([\\[\\]'{}()<>`@_*|!~$])", "$1");
output = output.replaceAll("\\\\([\\[\\]'{}()<>`@_*|!~$#])", "$1");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: We should be careful with the characters we unescape. Since our docstrings are in markdown, # is a format specifier for headings if it's at the beginning of a line. If we ever have a case where we unescape and it exists at the beginning of a line, it will lead to the entire line being a heading.

It's definitely a small risk but I think we may be able to escape it as \\# to avoid this issue entirely. However, this is also an issue for any Markdown character that can change the line formatting (e.g.> for code blocks). We might consider a double backslash for all the markdown characters but that makes the in-code docstrings more noisy.

This should be fine for now, but we should follow up to update how we escape markdown characters if it becomes a large issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to me. We should look into it more deeply if there is a large issue in the future.


// Replace <note> and <important> tags with admonitions for mkdocstrings
output = replaceAdmonitionTags(output, "note", "Note");
Expand Down
Loading