kwin commented on code in PR #236: URL: https://github.com/apache/maven-doxia/pull/236#discussion_r1803112831
########## 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: This happens during `Xhtml5BaseSink.write(....)`, but not in the MarkdownSink equivalent `writeUnescaped(....)`. Let's leave this for later, only very remotely related to this issue. -- 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: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org