Correct formatting for IE and PDF export
This commit is contained in:
@@ -226,6 +226,9 @@ public class JetMacro extends BaseMacro {
|
||||
case '&':
|
||||
builder.append("&");
|
||||
break;
|
||||
case ' ':
|
||||
builder.append(" ");
|
||||
break;
|
||||
case '"':
|
||||
builder.append(""");
|
||||
break;
|
||||
@@ -235,6 +238,24 @@ public class JetMacro extends BaseMacro {
|
||||
}
|
||||
}
|
||||
|
||||
private String addNewLineOpenTag() {
|
||||
return "<div class=\"line\">";
|
||||
}
|
||||
|
||||
private String addNewLineCloseTag() {
|
||||
return "</div>";
|
||||
}
|
||||
|
||||
private void addNewLines(StringBuilder result, String yytext) {
|
||||
for (int i = 0; i < yytext.length(); i++) {
|
||||
if (yytext.charAt(i) == '\n') {
|
||||
result.append(" ");
|
||||
result.append(addNewLineCloseTag());
|
||||
result.append(addNewLineOpenTag());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String execute(Map map, String code, RenderContext renderContext) throws MacroException {
|
||||
try {
|
||||
@@ -252,6 +273,8 @@ public class JetMacro extends BaseMacro {
|
||||
"<div class=\"container\">"
|
||||
);
|
||||
|
||||
result.append(addNewLineOpenTag());
|
||||
|
||||
_JetLexer jetLexer = new _JetLexer(DUMMY_READER);
|
||||
jetLexer.reset(afterPreprocessing, 0, afterPreprocessing.length(), _JetLexer.YYINITIAL);
|
||||
|
||||
@@ -284,7 +307,13 @@ public class JetMacro extends BaseMacro {
|
||||
IElementType token = jetLexer.advance();
|
||||
if (token == null) break;
|
||||
// CharSequence yytext = jetLexer.yytext();
|
||||
String yytext = jetLexer.yytext().toString().replaceAll("\n", "\r\n");
|
||||
String yytext = jetLexer.yytext().toString();
|
||||
|
||||
if (yytext.contains("\n")) {
|
||||
addNewLines(result, yytext);
|
||||
yytext = yytext.replaceAll("\n", "");
|
||||
}
|
||||
|
||||
String style = null;
|
||||
if (token instanceof JetKeywordToken) {
|
||||
style = "keyword";
|
||||
@@ -306,6 +335,7 @@ public class JetMacro extends BaseMacro {
|
||||
result.append("</code>");
|
||||
}
|
||||
|
||||
result.append(addNewLineCloseTag());
|
||||
result.append("</div>");
|
||||
result.append("</div>");
|
||||
result.append("</div>");
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
.jet {
|
||||
white-space: pre;
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.code {
|
||||
padding: 5px !important;
|
||||
}
|
||||
|
||||
.codeContent {
|
||||
margin: 5px !important;
|
||||
}
|
||||
|
||||
.line {
|
||||
white-space: pre !important;
|
||||
}
|
||||
|
||||
.jet.keyword {
|
||||
font-weight: bold;
|
||||
color: #369;
|
||||
|
||||
Reference in New Issue
Block a user