forked from JetBrains/kotlin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbc8e37
commit 8074629
Showing
6 changed files
with
195 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
confluence/src/main/java/org/jetbrains/jet/ConfluenceUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
package org.jetbrains.jet; | |||
|
|||
/** | |||
* @author Natalia.Ukhorskaya | |||
*/ | |||
|
|||
public class ConfluenceUtils { | |||
|
|||
public static void escapeHTML(StringBuilder builder, CharSequence seq) { | |||
if (seq == null) return; | |||
for (int i = 0; i < seq.length(); i++) { | |||
char c = seq.charAt(i); | |||
switch (c) { | |||
case '<': | |||
builder.append("<"); | |||
break; | |||
case '>': | |||
builder.append(">"); | |||
break; | |||
case '&': | |||
builder.append("&"); | |||
break; | |||
case ' ': | |||
builder.append(" "); | |||
break; | |||
case '"': | |||
builder.append("""); | |||
break; | |||
default: | |||
builder.append(c); | |||
} | |||
} | |||
} | |||
|
|||
public static String getErrorInHtml(Throwable e, String info) { | |||
StringBuilder stringBuilder = new StringBuilder(); | |||
stringBuilder.append("<div class=\"jet herror\">Jet highlighter error [").append(e.getClass().getSimpleName()).append("]: "); | |||
ConfluenceUtils.escapeHTML(stringBuilder, e.getMessage()); | |||
stringBuilder.append("<br/>"); | |||
stringBuilder.append("Original text:"); | |||
stringBuilder.append("<pre>"); | |||
ConfluenceUtils.escapeHTML(stringBuilder, info); | |||
stringBuilder.append("</pre>"); | |||
stringBuilder.append("</div>"); | |||
return stringBuilder.toString(); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.