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


Java Node类代码示例

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


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

示例1: process

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
    if (node instanceof Link) {
        Node previous = node.getPrevious();

        if (previous instanceof Text) {
            final BasedSequence chars = previous.getChars();

            //Se o nó anterior termina com '#' e é seguido pelo Link
            if (chars.endsWith("#") && chars.isContinuedBy(node.getChars())) {
                //Remove o caractere '#' do nó anterior.
                previous.setChars(chars.subSequence(0, chars.length() - 1));
                Twitter videoLink = new Twitter((Link) node);
                videoLink.takeChildren(node);
                node.unlink();
                previous.insertAfter(videoLink);
                state.nodeRemoved(node);
                state.nodeAddedWithChildren(videoLink);
            }
        }
    }
}
 
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:TwitterNodePostProcessor.java

示例2: process

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
    if (node instanceof Link) {
        Node previous = node.getPrevious();

        if (previous instanceof Text) {
            final BasedSequence chars = previous.getChars();

            //Se o nó anterior termina com 'B' e é seguido pelo Link
            if (chars.endsWith("B") && chars.isContinuedBy(node.getChars())) {
                //Remove o caractere 'B' do nó anterior.
                previous.setChars(chars.subSequence(0, chars.length() - 1));
                Button btn = new Button((Link) node);
                btn.takeChildren(node);
                node.unlink();
                previous.insertAfter(btn);
                state.nodeRemoved(node);
                state.nodeAddedWithChildren(btn);
            }
        }
    }
}
 
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:ButtonNodePostProcessor.java

示例3: process

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public void process(NodeTracker state, Node node) {
    if (node instanceof Link) {
        Node previous = node.getPrevious();

        if (previous instanceof Text) {
            final BasedSequence chars = previous.getChars();

            //Se o nó anterior termina com '@' e é seguido pelo Link
            if (chars.endsWith("@") && chars.isContinuedBy(node.getChars())) {
                //Remove o caractere '@' do nó anterior.
                previous.setChars(chars.subSequence(0, chars.length() - 1));
                VideoLink videoLink = new VideoLink((Link) node);
                videoLink.takeChildren(node);
                node.unlink();
                previous.insertAfter(videoLink);
                state.nodeRemoved(node);
                state.nodeAddedWithChildren(videoLink);
            }
        }
    }
}
 
开发者ID:tiagohm,项目名称:MarkdownView,代码行数:23,代码来源:VideoLinkNodePostProcessor.java

示例4: parse

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@SneakyThrows
public HashMap<String, Node> parse(final String fileContents) {
  final Node document = parser.parse(fileContents);
  final ReversiblePeekingIterable<Node> children = document.getChildren();
  final Stack<String> headingStack = new Stack<>();
  final HashMap<String, Node> documentTree = new HashMap<>();
  Paragraph subDocument = new Paragraph();
  documentTree.put("#", subDocument);
  for (final Node next : children) {
    final Optional<Paragraph> newSubDocument = resolveHeading(next)
      .map((Heading heading) -> {
        pushHeading(headingStack, heading);
        final String headingTitle = getHeadingTitle(headingStack);
        final Paragraph subDoc = new Paragraph();
        documentTree.put(headingTitle, subDoc);
        return subDoc;
      });
    if (newSubDocument.isPresent()) {
      subDocument = newSubDocument.get();
    }
    else {
      subDocument.appendChild(next);
    }
  }
  return documentTree;
}
 
开发者ID:camunda,项目名称:camunda-bpm-swagger,代码行数:27,代码来源:DocumentParser.java

示例5: convert

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public String convert(String input) throws SpecificationDialectException {
    try {
        if (isBlank(input)) {
            return EMPTY_STRING;
        }
        Node document = parser.parseReader(new StringReader(input));
        String render = renderer.render(document);
        // Ensure the result starts with html tags
        Document jsoupDoc = Jsoup.parse(render);
        LOGGER.debug("converted HTML:\n {}", jsoupDoc);
        return jsoupDoc.toString();
    } catch (IOException e) {
        throw new SpecificationDialectException("Can't parse the input.", e);
    }
}
 
开发者ID:strator-dev,项目名称:greenpepper,代码行数:17,代码来源:MarkdownDialect.java

示例6: MarkdownPreviewPane

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
public MarkdownPreviewPane() {
	pane.getStyleClass().add("preview-pane");

	previewContext = new PreviewContext() {
		@Override public Renderer getRenderer() { return activeRenderer; }
		@Override public String getMarkdownText() { return markdownText.get(); }
		@Override public Node getMarkdownAST() { return markdownAST.get(); }
		@Override public Path getPath() { return path.get(); }
		@Override public IndexRange getEditorSelection() { return editorSelection.get(); }
	};

	path.addListener((observable, oldValue, newValue) -> update() );
	markdownText.addListener((observable, oldValue, newValue) -> update() );
	markdownAST.addListener((observable, oldValue, newValue) -> update() );
	scrollY.addListener((observable, oldValue, newValue) -> scrollY());
	editorSelection.addListener((observable, oldValue, newValue) -> editorSelectionChanged());
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:18,代码来源:MarkdownPreviewPane.java

示例7: update

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public void update(String markdownText, Node astRoot, Path path) {
	assert markdownText != null;
	assert astRoot != null;

	if (this.astRoot == astRoot)
		return;

	this.markdownText = markdownText;
	this.astRoot = astRoot;
	this.path = path;

	astRoot2 = null;
	htmlPreview = null;
	htmlSource = null;
	ast = null;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:18,代码来源:FlexmarkPreviewRenderer.java

示例8: findSequences

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public List<Range> findSequences(int startOffset, int endOffset) {
	ArrayList<Range> sequences = new ArrayList<>();

	Node astRoot = toAstRoot();
	if (astRoot == null)
		return sequences;

	NodeVisitor visitor = new NodeVisitor(Collections.emptyList()) {
		@Override
		public void visit(Node node) {
			BasedSequence chars = node.getChars();
			if (isInSequence(startOffset, endOffset, chars))
				sequences.add(new Range(chars.getStartOffset(), chars.getEndOffset()));

			for (BasedSequence segment : node.getSegments()) {
				if (isInSequence(startOffset, endOffset, segment))
					sequences.add(new Range(segment.getStartOffset(), segment.getEndOffset()));
			}

			visitChildren(node);
		}
	};
	visitor.visit(astRoot);
	return sequences;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:27,代码来源:FlexmarkPreviewRenderer.java

示例9: toHtml

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
private String toHtml(boolean source) {
	Node astRoot = toAstRoot();
	if (astRoot == null)
		return "";

	HtmlRenderer.Builder builder = HtmlRenderer.builder()
			.extensions(MarkdownExtensions.getFlexmarkExtensions());
	if (!source)
		builder.attributeProviderFactory(new MyAttributeProvider.Factory());
	String html = builder.build().render(astRoot);

       for (PreviewRendererAddon addon : addons)
           html = addon.postRender(html, path);

       return html;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:17,代码来源:FlexmarkPreviewRenderer.java

示例10: formatParagraphs

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
List<Pair<Paragraph, String>> formatParagraphs(Node markdownAST, int wrapLength) {
	ArrayList<Pair<Paragraph, String>> formattedParagraphs = new ArrayList<>();
	NodeVisitor visitor = new NodeVisitor(Collections.emptyList()) {
		@Override
		public void visit(Node node) {
			if (node instanceof Paragraph) {
				Paragraph paragraph = (Paragraph) node;
				String newText = formatParagraph(paragraph, wrapLength);
				if (!paragraph.getChars().equals(newText, false))
					formattedParagraphs.add(new Pair<>(paragraph, newText));
			} else
				visitChildren(node);
		}
	};
	visitor.visit(markdownAST);
	return formattedParagraphs;
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:18,代码来源:SmartFormat.java

示例11: collectFormattableText

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
/**
 * Collects the text of a single paragraph.
 *
 * Replaces:
 *   - tabs with spaces
 *   - newlines with spaces (may occur in Code nodes)
 *   - soft line breaks with spaces
 *   - hard line breaks with special marker characters
 *   - spaces and tabs in special nodes, that should not formatted, with marker characters
 */
private void collectFormattableText(StringBuilder buf, Node node) {
	for (Node n = node.getFirstChild(); n != null; n = n.getNext()) {
		if (n instanceof Text) {
			buf.append(n.getChars().toString().replace('\t', ' ').replace('\n', ' '));
		} else if (n instanceof DelimitedNode) {
			// italic, bold and code
			buf.append(((DelimitedNode) n).getOpeningMarker());
			collectFormattableText(buf, n);
			buf.append(((DelimitedNode) n).getClosingMarker());
		} else if (n instanceof SoftLineBreak) {
			buf.append(' ');
		} else if (n instanceof HardLineBreak) {
			buf.append(' ').append(n.getChars().startsWith("\\")
				? HARD_LINE_BREAK_BACKSLASH : HARD_LINE_BREAK_SPACES).append(' ');
		} else {
			// other text that should be not wrapped or formatted
			buf.append(protectWhitespace(n.getChars().toString()));
		}
	}
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:31,代码来源:SmartFormat.java

示例12: findIndentableNodesAtSelection

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
private List<Node> findIndentableNodesAtSelection() {
	if (!indentNodes)
		return Collections.emptyList();

	return findNodesAtSelectedLines((start, end, node) -> {
		if (!(node instanceof ListItem))
			return false;

		// match only if one non-ListBlock child is in range
		for (Node child : node.getChildren()) {
			if (isInNode(start, end, child) && !(child instanceof ListBlock))
				return true;
		}
		return false;
	}, false, false);
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:17,代码来源:SmartEdit.java

示例13: indentNodes

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
private void indentNodes(List<Node> nodes, boolean right) {
	StringBuilder buf = new StringBuilder();
	for (int i = 0; i < nodes.size(); i++) {
		Node node = nodes.get(i);
		if (i > 0)
			buf.append(textArea.getText(nodes.get(i - 1).getEndOffset(), node.getStartOffset()));

		// indent list items
		if (node instanceof ListItem) {
			String str = node.getChars().toString();
			str = indentText(str, right);
			buf.append(str);
		}
	}

	int start = nodes.get(0).getStartOffset();
	int end = nodes.get(nodes.size() - 1).getEndOffset();

	IndentSelection isel = rememberIndentSelection();
	replaceText(textArea, start, end, buf.toString());
	selectAfterIndent(isel);
}
 
开发者ID:JFormDesigner,项目名称:markdown-writer-fx,代码行数:23,代码来源:SmartEdit.java

示例14: resolveLink

import com.vladsch.flexmark.ast.Node; //导入依赖的package包/类
@Override
public ResolvedLink resolveLink(Node node, LinkResolverContext context, ResolvedLink link) {
    ResolvedLink result = link;

    for (String inputFileExtension : inputFileExtensions) {
        if (link.getLinkType() == LinkType.LINK) {
            String url = link.getUrl();
            if (!url.startsWith("http://") && !url.startsWith("https://")) {
                if (url.endsWith("." + inputFileExtension)) {
                    url = url.substring(0, url.length() - inputFileExtension.length()) + "html";
                    result = result.withStatus(LinkStatus.VALID).withUrl(url);
                    return result;
                } else if (url.contains("." + inputFileExtension + "#")) {
                    url = url.replace("." + inputFileExtension + "#", ".html#");
                    result = result.withStatus(LinkStatus.VALID).withUrl(url);
                    return result;
                }
            }
        }
    }

    return result;
}
 
开发者ID:walokra,项目名称:markdown-page-generator-plugin,代码行数:24,代码来源:FlexmarkLinkResolver.java

示例15: setAttributes

import com.vladsch.flexmark.ast.Node; //导入依赖的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


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