Skip to content

Instantly share code, notes, and snippets.

@Izaron
Created June 16, 2016 10:32
Show Gist options
  • Save Izaron/c881435623f5fc911d226f209b505fb1 to your computer and use it in GitHub Desktop.
Save Izaron/c881435623f5fc911d226f209b505fb1 to your computer and use it in GitHub Desktop.
String generateHtml(String codeTheme, String lineNumbersProperty, String font, String sourceCode) {
if (!lineNumbersProperty.isEmpty()) {
return "<link rel=\"stylesheet\" href=\"styles-hl/" + codeTheme + ".css\">\n" +
"<script src=\"highlight.pack.js\"></script>\n" +
"<script src=\"highlightjs-line-numbers.js\"></script>\n" +
"<script>hljs.initHighlightingOnLoad();</script>\n" +
"<script>hljs.initLineNumbersOnLoad();</script>\n" +
"<link rel=\"stylesheet\" href=\"lines.css\">\n" +
"<style type=\"text/css\">.hljs {\n" +
" font-family: \"" + font + "\";\n" +
"}\n" +
"</style>\n" +
"<html><body> <pre><code class=\"java\" >" + sourceCode + "</code></pre> </body></html>";
} else {
return "<link rel=\"stylesheet\" href=\"styles-hl/" + codeTheme + ".css\">\n" +
"<script src=\"highlight.pack.js\"></script>\n" +
"<script>hljs.initHighlightingOnLoad();</script>\n" +
"<link rel=\"stylesheet\" href=\"lines.css\">\n" +
"<style type=\"text/css\">.hljs {\n" +
" padding-left: 0.5em;\n" +
" font-family: \"" + font + "\";\n" +
"}\n" +
"</style>\n" +
"<html><body> <pre><code class=\"java\" >" + sourceCode + "</code></pre> </body></html>";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment