当前位置: 首页>>代码示例>>Java>>正文


Java Attributes类代码示例

本文整理汇总了Java中com.vladsch.flexmark.util.html.Attributes的典型用法代码示例。如果您正苦于以下问题:Java Attributes类的具体用法?Java Attributes怎么用?Java Attributes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Attributes类属于com.vladsch.flexmark.util.html包,在下文中一共展示了Attributes类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAttributes

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
@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)"));
    }
}
 
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:38,代码来源:MarkdownView.java

示例2: execute

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
/**
 * 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);
    preprocessMarkdownFiles(new File(inputDirectory));

    if (!markdownDTOs.isEmpty()) {
        getLog().info("Process Pegdown extension options");
        int options = getPegdownExtensions(pegdownExtensions);
        final Map<String, Attributes> attributesMap = processAttributes(attributes);

        getLog().info("Parse Markdown to HTML");
        processMarkdown(markdownDTOs, options, 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());
            }
        }
    }
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:36,代码来源:MdPageGeneratorMojo.java

示例3: processAttributes

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
/**
 * 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) {
    HashMap<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;
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:33,代码来源:MdPageGeneratorMojo.java

示例4: setAttributes

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
@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);
        }
    }
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:10,代码来源:FlexmarkAttributeProvider.java

示例5: extend

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
@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));
						}
					}
				}
				
			};
		}
	});
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:42,代码来源:SourcePositionTrackExtension.java

示例6: attr

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
@Override
public HtmlBuilder attr(final Attributes attributes) {
    super.withAttr();
    return super.attr(attributes);
}
 
开发者ID:vsch,项目名称:MissingInActions,代码行数:6,代码来源:HtmlBuilder.java

示例7: setAttributes

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
public void setAttributes(Node node, AttributablePart part, 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(
                        MarkdownView.HIGHLIGHTJS);
                addJavascript(
                        MarkdownView.HIGHLIGHT_INIT);
                attributes.addValue("language", language);
                attributes.addValue("onclick", String.format(
                        "javascript:android.onCodeTap(\'%s\', this.textContent);",
                        language));
            }
        }
    } else if (node instanceof MathJax) {
        addJavascript(MarkdownView.MATHJAX);
        addJavascript(
                MarkdownView.MATHJAX_CONFIG);
    } else if (node instanceof Abbreviation) {
        addJavascript(
                MarkdownView.TOOLTIPSTER_JS);
        addStyleSheet(
                MarkdownView.TOOLTIPSTER_CSS);
        addJavascript(
                MarkdownView.TOOLTIPSTER_INIT);
        attributes.addValue("class", "tooltip");
    } else if (node instanceof Heading) {
        attributes.addValue("onclick",
                String.format(Locale.getDefault(),
                        "javascript:android.onHeadingTap(%d, \'%s\');",
                        ((Heading) node).getLevel(),
                        ((Heading) node).getText()));
    } else if (node instanceof Image) {
        attributes.addValue("onclick",
                "javascript: android.onImageTap(this.src, this.clientWidth, this.clientHeight);");
    } else if (node instanceof Mark) {
        attributes.addValue("onclick", "javascript: android.onMarkTap(this.textContent)");
    } else if (node instanceof Keystroke) {
        attributes.addValue("onclick",
                "javascript: android.onKeystrokeTap(this.textContent)");
    } else if (node instanceof Link || node instanceof AutoLink) {
        attributes.addValue("onclick",
                "javascript: android.onLinkTap(this.href, this.textContent)");
    }

}
 
开发者ID:sorcererXW,项目名称:SorceryIconPack,代码行数:48,代码来源:AsynMarkdownView.java

示例8: setAttributes

import com.vladsch.flexmark.util.html.Attributes; //导入依赖的package包/类
@Override
public void setAttributes(Node node, AttributablePart part, Attributes attributes) {
	attributes.addValue("data-pos", node.getStartOffset() + ":" + node.getEndOffset());
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:5,代码来源:FlexmarkPreviewRenderer.java


注:本文中的com.vladsch.flexmark.util.html.Attributes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。