use of syntaxhighlight.ParseResult in project gitiles by GerritCodeReview.
the class MarkdownToHtml method codeInPre.
private void codeInPre(String lang, String text) {
html.open("pre").attribute("class", "code");
text = printLeadingBlankLines(text);
List<ParseResult> parsed = parse(lang, text);
if (parsed != null) {
int last = 0;
for (ParseResult r : parsed) {
span(null, text, last, r.getOffset());
last = r.getOffset() + r.getLength();
span(r.getStyleKeysString(), text, r.getOffset(), last);
}
if (last < text.length()) {
span(null, text, last, text.length());
}
} else {
html.appendAndEscape(text);
}
html.close("pre");
}
use of syntaxhighlight.ParseResult in project gitiles by GerritCodeReview.
the class BlobSoyData method prettify.
private SoyListData prettify(String path, String content) {
List<ParseResult> results = parse(path, content);
SoyListData lines = new SoyListData();
SoyListData line = new SoyListData();
lines.add(line);
int last = 0;
for (ParseResult r : results) {
checkState(r.getOffset() >= last, "out-of-order ParseResult, expected %s >= %s", r.getOffset(), last);
writeResult(lines, null, content, last, r.getOffset());
last = r.getOffset() + r.getLength();
writeResult(lines, r.getStyleKeysString(), content, r.getOffset(), last);
}
if (last < content.length()) {
writeResult(lines, null, content, last, content.length());
}
return lines;
}
Aggregations