15
15
16
16
public class Main {
17
17
private static final Pattern PATTERN =Pattern .compile ("\\ r?\\ n" );
18
+ private static final Pattern CODE_BLOCK =Pattern .compile ("(`)(.*?)(`)" );
18
19
19
20
private static void fillFilesRecursively (Path directory ,final List <File >resultFiles )
20
21
throws IOException {
@@ -111,41 +112,20 @@ public static void main(String[] args) throws IOException {
111
112
};
112
113
String readmeMdJavadoc =
113
114
"/**\n "
114
- +StringUtils .replaceEach (
115
- StringUtils .replaceEach (
116
- PATTERN .splitAsStream (readmeMdText )
117
- .map (
118
- line -> {
119
- String firstLine =
120
- line
121
- .replace (
122
- "\\ ." ,
123
- " -" )
124
- +"\\ ." ;
125
- String str =
126
- index [0 ]++
127
- ==0
128
- ?firstLine
129
- :line ;
130
- return line
131
- .isEmpty ()
132
- ?" *"
133
- :" * "
134
- +str ;
135
- })
136
- .collect (
137
- Collectors .joining (
138
- "\n " )),
139
- fromStr ,
140
- toStr ),
141
- fromStr2 ,
142
- toStr2 )
143
- .replace ("`**" ,"` **" )
144
- .replace (",**" ,", **" )
145
- .replace ("<ins>**" ,"<ins> **" )
146
- .replace ("**</ins>" ,"** </ins>" )
147
- .replace ("/*" ,"{@literal /}*" )
148
- .replace ("*/" ,"*{@literal /}" )
115
+ +replaceCode (
116
+ StringUtils .replaceEach (
117
+ StringUtils .replaceEach (
118
+ getText (readmeMdText ,index ),
119
+ fromStr ,
120
+ toStr ),
121
+ fromStr2 ,
122
+ toStr2 )
123
+ .replace ("`**" ,"` **" )
124
+ .replace (",**" ,", **" )
125
+ .replace ("<ins>**" ,"<ins> **" )
126
+ .replace ("**</ins>" ,"** </ins>" )
127
+ .replace ("/*" ,"{@literal /}*" )
128
+ .replace ("*/" ,"*{@literal /}" ))
149
129
+"\n **/" ;
150
130
String publicClass =
151
131
solutionJavaText .contains ("@SuppressWarnings" )
@@ -157,6 +137,21 @@ public static void main(String[] args) throws IOException {
157
137
}
158
138
}
159
139
140
+ private static String getText (String readmeMdText ,int []index ) {
141
+ return PATTERN .splitAsStream (readmeMdText )
142
+ .map (
143
+ line -> {
144
+ String firstLine =line .replace ("\\ ." ," -" ) +"\\ ." ;
145
+ String str =index [0 ]++ ==0 ?firstLine :line ;
146
+ return line .isEmpty () ?" *" :" * " +str ;
147
+ })
148
+ .collect (Collectors .joining ("\n " ));
149
+ }
150
+
151
+ private static String replaceCode (String code ) {
152
+ return CODE_BLOCK .matcher (code ).replaceAll ("<code>$2</code>" );
153
+ }
154
+
160
155
private static byte []getBytes (
161
156
String solutionJavaText ,String readmeMdJavadoc ,String publicClass ) {
162
157
return solutionJavaText