Modify issue#565 - Do not render questions in HTML documents. #567
-
Bug localizationUpon inspecting the /template/html/index.html template, two differences were identified as follows: Template code that properly renders HTML formatting. <div class="paragraph"><p><strong>Description:</strong>${lineBreaksToBr(doc.detail)}</p></div> Template code that improperly renders HTML formatting.<td class="tableblock halign-left valign-top"><p class="tableblock">${htmlEscape(param.desc)}</p></td> Continue to trace into the Java code The LineBreaksToBr.class that properly renders HTML formatting. public String call(Object[] paras, Context ctx) {
String str = String.valueOf(paras[0]);
return HtmlUtil.lineBreaksToBr(str);
} The HtmlEscape.class that improperly renders HTML formatting. public String call(Object[] paras, Context ctx) {
String str = String.valueOf(paras[0]).replaceAll("&", "&");
str = str.replaceAll("\"", """);
str = str.replaceAll("<p>", "").replaceAll("</p>", " ");
return DocUtil.replaceNewLineToHtmlBr(DocUtil.getEscapeAndCleanComment(str));
} Reason for the exceptionThe HtmlEscape.call() 中调用的 DocUtil.getEscapeAndCleanComment()。 会将所有的大于小于符合变成转移字符,导致所有的html标签都无法变成html元素. 查看了git提交记录,发现是在commit 0c8bc04 调用了该方法,自此smart-doc就失去了字段上html格式渲染的能力。 update: Optimized handling of special greater-than and less-than symbols in documents
0c8bc045 shalousun <smartdoc647@gmail.com> on 2022/4/3 at 14:46 SolutionRemove the call to DocUtil.getEscapeAndCleanComment().The simplest solution is to remove the call. However, it's not possible to assess the impact of its removal (I don't understand the purpose of this optimization). Refer to the implementation of JavaDocReferencing JavaDoc's support for HTML elements, further reference will be made later, followed by a proposed solution. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This issue stems from historical reasons; smart-doc has actually been around for several years. In its early days, some methods were developed to address issues with rendering Markdown. For HTML, it's necessary to conduct a series of tests because an improper element might cause problems with the webpage. HTML testing can be aligned with what JavaDoc HTML supports. As long as the page functions correctly, it's fine. It's feasible to individually test and modify Beetl's custom functions for various template issues. |
Beta Was this translation helpful? Give feedback.
This issue stems from historical reasons; smart-doc has actually been around for several years. In its early days, some methods were developed to address issues with rendering Markdown. For HTML, it's necessary to conduct a series of tests because an improper element might cause problems with the webpage. HTML testing can be aligned with what JavaDoc HTML supports. As long as the page functions correctly, it's fine. It's feasible to individually test and modify Beetl's custom functions for various template issues.
这个是一些历史原因,smart-doc其实好几年了,早期的时候有的是为了解决早期markdown渲染问题编写的方法。html需要写一些测试,某一元素不合理可能会导致页面有问题。html可以按照javadoc html能支持的做些测试。保证页面不出问题就可以,可以单独对各种模版的问题测一测和改改beetl的自定义函数