michael-o commented on code in PR #236:
URL: https://github.com/apache/maven-doxia/pull/236#discussion_r1802489161
##########
doxia-core/src/main/java/org/apache/maven/doxia/sink/impl/Xhtml5BaseSink.java:
##########
@@ -1444,34 +1444,44 @@ public void rawText(String text) {
}
}
- /** {@inheritDoc} */
@Override
public void comment(String comment) {
+ comment(comment, false);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void comment(String comment, boolean endsWithLineBreak) {
if (comment != null) {
- final String originalComment = comment;
+ write(encodeAsHtmlComment(comment, endsWithLineBreak,
getLocationLogPrefix()));
+ }
+ }
- // http://www.w3.org/TR/2000/REC-xml-20001006#sec-comments
- while (comment.contains("--")) {
- comment = comment.replace("--", "- -");
- }
+ public static String encodeAsHtmlComment(String comment, boolean
endsWithLineBreak, String locationLogPrefix) {
+ final String originalComment = comment;
- if (comment.endsWith("-")) {
- comment += " ";
- }
+ // http://www.w3.org/TR/2000/REC-xml-20001006#sec-comments
+ while (comment.contains("--")) {
+ comment = comment.replace("--", "- -");
+ }
- if (!originalComment.equals(comment)) {
- LOGGER.warn(
- "{}Modified invalid comment '{}' to '{}'",
getLocationLogPrefix(), originalComment, comment);
- }
+ if (comment.endsWith("-")) {
+ comment += " ";
+ }
- final StringBuilder buffer = new StringBuilder(comment.length() +
7);
+ if (!originalComment.equals(comment)) {
+ LOGGER.warn("{}Modified invalid comment '{}' to '{}'",
locationLogPrefix, originalComment, comment);
+ }
- buffer.append(LESS_THAN).append(BANG).append(MINUS).append(MINUS);
- buffer.append(comment);
- buffer.append(MINUS).append(MINUS).append(GREATER_THAN);
+ final StringBuilder buffer = new StringBuilder(comment.length() + 7);
- write(buffer.toString());
+ buffer.append(LESS_THAN).append(BANG).append(MINUS).append(MINUS);
+ buffer.append(comment);
+ buffer.append(MINUS).append(MINUS).append(GREATER_THAN);
+ if (endsWithLineBreak) {
+ buffer.append(EOL);
}
+ return buffer.toString();
Review Comment:
Do you want to normalize line endings in the actual comments as well?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]