List of usage examples for org.jsoup.nodes Element addClass
public Element addClass(String className)
From source file:com.aestasit.markdown.slidery.converters.DeckJSConverter.java
protected void transformDocument(final Document slidesDocument, final Configuration config) { super.transformDocument(slidesDocument, config); if (config.listsIncremented()) { for (final Element list : slidesDocument.select("div li")) { list.addClass("slide"); }//from ww w.j av a2 s . c o m } }
From source file:com.assignmentone.snippet.ShowCodeSnippet.java
private Element makeShowHtml(String file, String title, String contents) { // create the panel tag Element panel = new Element(Tag.valueOf("div"), ""); panel.addClass("panel"); panel.addClass("panel-default"); Element heading = new Element(Tag.valueOf("div"), ""); heading.addClass("panel-heading"); Element body = new Element(Tag.valueOf("div"), ""); body.addClass("panel-body"); panel.appendChild(heading);//from w w w .j a v a 2s.co m panel.appendChild(body); // write title and file path String headStr = StringUtils.isEmpty(title) ? "" : title + ":"; headStr += file; heading.appendText(headStr); // create the pre tag Element pre = new Element(Tag.valueOf("pre"), ""); pre.addClass("prettyprint source"); pre.attr("style", "overflow-x:auto"); if (contents != null) { pre.appendChild(new Element(Tag.valueOf("span"), "").appendText(contents)); } body.appendChild(pre); return panel; }
From source file:com.aestasit.markdown.slidery.converters.TextTemplateConverter.java
private void renderSyntaxHighlightingHtml(final Document slidesDocument, final Configuration config) { for (Element code : slidesDocument.select("code")) { Charset encoding = config.getInputEncoding(); ByteArrayInputStream input = new ByteArrayInputStream(code.text().getBytes(encoding)); ByteArrayOutputStream out = new ByteArrayOutputStream(); String className = code.className(); if (StringUtils.isBlank(className)) { className = "java"; }/*from ww w .j a v a 2 s. com*/ Renderer renderer = XhtmlRendererFactory.getRenderer(className); if (renderer != null) { try { renderer.highlight("slidery", input, out, encoding.name(), true); code.html(new String(out.toByteArray(), encoding)); code.select("br").remove(); removeComments(code); code.html(code.html().trim()); Element parent = code.parent(); if (parent.tagName() == "pre") { parent.addClass("code"); } } catch (IOException e) { // TODO: Handle exception } } } }