com.vladsch.flexmark.util.html.Attributes Java Examples
The following examples show how to use
com.vladsch.flexmark.util.html.Attributes.
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: MdPageGeneratorMojo.java From markdown-page-generator-plugin with MIT License | 5 votes |
/** * Execute the maven plugin. * * @throws MojoExecutionException Something went wrong */ @Override public void execute() throws MojoExecutionException { // First, if filtering is enabled, perform that using the Maven magic if (applyFiltering) { performMavenPropertyFiltering(new File(inputDirectory), filteredOutputDirectory, getInputEncoding()); inputDirectory = filteredOutputDirectory.getAbsolutePath(); } getLog().info("Pre-processing markdown files from input directory: " + inputDirectory); if (!preprocessMarkdownFiles(new File(inputDirectory))){ getLog().info("Pre-processing markdown files from input directory: markdown files not found" + inputDirectory); return; } if (!markdownDTOs.isEmpty()) { getLog().info("Process Pegdown extension options"); int pegdownOptions = getPegdownExtensions(pegdownExtensions); MutableDataHolder flexmarkOptions = getFlexmarkParserOptions(flexmarkParserOptions); final Map<String, Attributes> attributesMap = processAttributes(attributes); getLog().info("Parse Markdown to HTML"); processMarkdown(markdownDTOs, pegdownOptions, flexmarkOptions, attributesMap); } // FIXME: This will possibly overwrite any filtering updates made in the maven property filtering step above if (StringUtils.isNotEmpty(copyDirectories)) { getLog().info("Copy files from directories"); for (String dir : copyDirectories.split(",")) { for (Entry<String, String> copyAction : getFoldersToCopy(inputDirectory, outputDirectory, dir).entrySet()) { copyFiles(copyAction.getKey(), copyAction.getValue()); } } } }
Example #3
Source File: MdPageGeneratorMojo.java From markdown-page-generator-plugin with MIT License | 5 votes |
/** * Parse attributes of the form NodeName:attributeName=attribute value:attributeName=attribute value... * * @param attributeList list of attributes * @return map of Node class to attributable part and attributes */ private Map<String, Attributes> processAttributes(String[] attributeList) { Map<String, Attributes> nodeAttributeMap = new HashMap<>(); for (String attribute : attributeList) { String[] nodeAttributes = attribute.split("\\|"); Attributes attributes = new Attributes(); for (int i = 1; i < nodeAttributes.length; i++) { String[] attributeNameValue = nodeAttributes[i].split("=", 2); if (attributeNameValue.length > 1) { String value = attributeNameValue[1]; if (!value.isEmpty()) { if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') { value = value.substring(1, value.length() - 1); } else if (value.charAt(0) == '\'' && value.charAt(value.length() - 1) == '\'') { value = value.substring(1, value.length() - 1); } } attributes.addValue(attributeNameValue[0], value); } else { attributes.addValue(attributeNameValue[0], attributeNameValue[0]); } } nodeAttributeMap.put(nodeAttributes[0], attributes); } return nodeAttributeMap; }
Example #4
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 #5
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 #6
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 #7
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()); }