com.vladsch.flexmark.html.renderer.AttributablePart Java Examples
The following examples show how to use
com.vladsch.flexmark.html.renderer.AttributablePart.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarkdownView.java From MarkdownView with Apache License 2.0 | 5 votes |
@Override public void setAttributes(final Node node, final AttributablePart part, final Attributes attributes) { if (node instanceof FencedCodeBlock) { if (part.getName().equals("NODE")) { String language = ((FencedCodeBlock) node).getInfo().toString(); if (!TextUtils.isEmpty(language) && !language.equals("nohighlight")) { addJavascript(HIGHLIGHTJS); addJavascript(HIGHLIGHT_INIT); attributes.addValue("language", language); //attributes.addValue("onclick", String.format("javascript:android.onCodeTap('%s', this.textContent);", // language)); } } } else if (node instanceof MathJax) { addJavascript(MATHJAX); addJavascript(MATHJAX_CONFIG); } else if (node instanceof Abbreviation) { addJavascript(TOOLTIPSTER_JS); addStyleSheet(TOOLTIPSTER_CSS); addJavascript(TOOLTIPSTER_INIT); attributes.addValue("class", "tooltip"); } else if (node instanceof Heading) { //attributes.addValue("onclick", String.format("javascript:android.onHeadingTap(%d, '%s');", // ((Heading) node).getLevel(), ((Heading) node).getText())); } else if (node instanceof Image) { //attributes.addValue("onclick", String.format("javascript: android.onImageTap(this.src, this.clientWidth, this.clientHeight);")); } else if (node instanceof Mark) { //attributes.addValue("onclick", String.format("javascript: android.onMarkTap(this.textContent)")); } else if (node instanceof Keystroke) { //attributes.addValue("onclick", String.format("javascript: android.onKeystrokeTap(this.textContent)")); } else if (node instanceof Link || node instanceof AutoLink) { //attributes.addValue("onclick", String.format("javascript: android.onLinkTap(this.href, this.textContent)")); } }
Example #2
Source File: FlexmarkAttributeProvider.java From markdown-page-generator-plugin with MIT License | 5 votes |
@Override public void setAttributes(Node node, AttributablePart part, Attributes attributes) { if (attributeMap != null) { Attributes attributes1 = attributeMap.get(node.getClass().getSimpleName()); if (attributes1 != null) { attributes.replaceValues(attributes1); } } }
Example #3
Source File: CustomAttributeProvider.java From OmniList with GNU Affero General Public License v3.0 | 4 votes |
@Override public void setAttributes(final Node node, final AttributablePart part, final Attributes attributes) {}
Example #4
Source File: SourcePositionTrackExtension.java From onedev with MIT License | 4 votes |
@Override public void extend(Builder rendererBuilder, String rendererType) { rendererBuilder.attributeProviderFactory(new IndependentAttributeProviderFactory() { @Override public AttributeProvider create(NodeRendererContext context) { return new AttributeProvider() { @Override public void setAttributes(Node node, AttributablePart part, Attributes attributes) { if (node instanceof Block) { int startOffset = node.getStartOffset(); int endOffset = node.getEndOffset(); Node document = node.getDocument(); if (document != null) { int leadingWhitespaces = 0; for (int i=startOffset; i<endOffset; i++) { if (Character.isWhitespace(document.getChars().charAt(i))) { leadingWhitespaces++; } else { break; } } int trailingWhitespaces = 0; for (int i=endOffset-1; i>=startOffset; i--) { if (Character.isWhitespace(document.getChars().charAt(i))) { trailingWhitespaces++; } else { break; } } attributes.addValue("data-" + DATA_START_ATTRIBUTE, String.valueOf(startOffset+leadingWhitespaces)); attributes.addValue("data-" + DATA_END_ATTRIBUTE, String.valueOf(endOffset-trailingWhitespaces)); } } } }; } }); }
Example #5
Source File: FlexmarkPreviewRenderer.java From markdown-writer-fx with BSD 2-Clause "Simplified" License | 4 votes |
@Override public void setAttributes(Node node, AttributablePart part, Attributes attributes) { attributes.addValue("data-pos", node.getStartOffset() + ":" + node.getEndOffset()); }