Skip to content

Commit 8cf7b35

Browse files
committed
close #709
1 parent f95faf4 commit 8cf7b35

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/main/java/com/shuzijun/leetcode/plugin/model/CodeTypeEnum.java

+7-1
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,17 @@ public enum CodeTypeEnum {
2121
KOTLIN("Kotlin", "kotlin", ".kt", "//", "/**\n%s\n*/"),
2222
RUST("Rust", "rust", ".rs", "//", "/**\n%s\n*/"),
2323
PHP("PHP", "php", ".php", "//", "/**\n%s\n*/"),
24+
TypeScript("TypeScript", "typescript", ".ts", "//", "/**\n%s\n*/"),
25+
Dart("Dart", "dart", ".dart", "//", "/**\n%s\n*/"),
26+
Racket("Racket", "racket", ".rkt", ";", "#|\n%s\n|#"),
27+
Erlang("Erlang", "erlang", ".erl", "%", ""),
28+
Elixir("Elixir", "elixir", ".ex", "#", ""),
2429
BASH("Bash", "bash", ".sh", "#",": '\n%s\n'"),
2530
MYSQL("MySQL", "mysql", ".sql", "#", "/**\n%s\n*/"),
2631
ORACLE("Oracle", "oraclesql", ".sql", "#", "/**\n%s\n*/"),
2732
MSSQLSERVER("MS SQL Server", "mssql", ".sql", "#", "/**\n%s\n*/"),
28-
TypeScript("TypeScript", "typescript", ".ts", "//", "/**\n%s\n*/"),
33+
Pandas("Pandas", "pythondata", ".py", "#", "\"\"\"\n%s\n\"\"\""),
34+
PostgreSQL("PostgreSQL", "postgresql", ".sql", "--", "/**\n%s\n*/"),
2935
;
3036

3137

src/main/java/com/shuzijun/leetcode/plugin/utils/CommentUtils.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ public class CommentUtils {
1616
private static final Pattern subPattern = Pattern.compile("<sup>(<span.*>?)?([0-9abcdeghijklmnoprstuvwxyz\\+\\-\\*=\\(\\)\\.\\/]+)(</span>)?</sup>?");
1717

1818
public static String createComment(String html, CodeTypeEnum codeTypeEnum, Config config) {
19+
boolean isSupportMultilineComment = config.getMultilineComment() && StringUtils.isNotBlank(codeTypeEnum.getMultiLineComment());
1920
html = html.replaceAll("(\\r\\n|\\r|\\n|\\n\\r)", "\\\\n").replaceAll(" "," ");
2021
if(config.getHtmlContent()) {
21-
if(config.getMultilineComment()){
22+
if(isSupportMultilineComment){
2223
return String.format(codeTypeEnum.getMultiLineComment(),html.replaceAll("\\\\n", "\n"));
2324
}else {
2425
return codeTypeEnum.getComment() + html.replaceAll("\\\\n", "\n" + codeTypeEnum.getComment());
@@ -29,7 +30,7 @@ public static String createComment(String html, CodeTypeEnum codeTypeEnum, Confi
2930
String subStr = SuperscriptUtils.getSup(subMatcher.group(2));
3031
html = html.replace(subMatcher.group(), "<sup>" + subStr + "</sup>");
3132
}
32-
String comment = config.getMultilineComment()?"":codeTypeEnum.getComment();
33+
String comment = isSupportMultilineComment?"":codeTypeEnum.getComment();
3334
String body = comment + Jsoup.parse(html).text().replaceAll("\\\\n", "\n" + comment);
3435
String[] lines = body.split("\n");
3536
StringBuilder sb = new StringBuilder();
@@ -52,7 +53,7 @@ public static String createComment(String html, CodeTypeEnum codeTypeEnum, Confi
5253
sb.append(lineBuilder).append("\n");
5354
}
5455
}
55-
return config.getMultilineComment()?String.format(codeTypeEnum.getMultiLineComment(),sb):sb.toString();
56+
return isSupportMultilineComment?String.format(codeTypeEnum.getMultiLineComment(),sb):sb.toString();
5657
}
5758

5859
public static String createSubmissions(String html) {

0 commit comments

Comments
 (0)