Skip to content

Commit

Permalink
Doc-gen: trim-right before style changes (#8459)
Browse files Browse the repository at this point in the history
In markdown, for styles applied using `_` or `**` there must not be any whitespaces, otherwise the `_` and `**` will appear as is.
  • Loading branch information
snazy authored May 6, 2024
1 parent e8ef4fb commit ff7e173
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ void maybeAddSeparator() {
}
text.append(' ');
}

void trimRight() {
int l = text.length();
while (l > 0 && Character.isWhitespace(text.charAt(l - 1))) {
text.setLength(--l);
}
}
}

private class MDFormat {
Expand Down Expand Up @@ -491,9 +498,11 @@ private void process(DocTree doc) {
break;
case "em":
case "i":
target.trimRight();
target.text.append('_');
break;
case "b":
target.trimRight();
target.text.append("**");
break;
case "ol":
Expand Down

0 comments on commit ff7e173

Please sign in to comment.