Package org.pegdown.ast

Examples of org.pegdown.ast.Node


    Rule Line() {
        StringVar line = new StringVar();
        return Sequence(
                ZeroOrMore(TestNot('\r'), TestNot('\n'), ANY), line.set(match() + '\n'),
                Newline(),
                push(new Node(line.get()))
        );
    }
View Full Code Here


        );
    }

    Rule AbbreviationText(Var<AbbreviationNode> node) {
        return Sequence(
                node.get().setExpansion(new Node()),
                ZeroOrMore(TestNot(Newline()), Inline(), node.get().getExpansion().addChild(pop()))
        );
    }
View Full Code Here

    public Printer printChildren(Node node) {
        StringBuilder sb = new StringBuilder();
        List<Node> children = node.getChildren();
        for (int i = 0, childrenSize = children.size(); i < childrenSize; i++) {
            Node child = children.get(i);
            if (child instanceof TextNode) {
                sb.append(child.getText());
            } else {
                if (sb.length() > 0) {
                    printWithAbbreviations(sb.toString());
                    sb.setLength(0);
                }
                child.print(this);
            }
        }
        if (sb.length() > 0) printWithAbbreviations(sb.toString());
        return this;
    }
View Full Code Here

    //************* BLOCKS ****************

    Rule Doc() {
        return Sequence(
                push(new Node()),
                ZeroOrMore(Block(), peek(1).addChild(pop()))
        );
    }
View Full Code Here

        );
    }

    Rule ListTight() {
        return Sequence(
                ListItem(true), push(new Node(pop())),
                ZeroOrMore(ListItem(true), peek(1).addChild(pop())),
                ZeroOrMore(BlankLine()),
                TestNot(FirstOf(Bullet(), Enumerator()))
        );
    }
View Full Code Here

        );
    }

    Rule ListLoose() {
        return Sequence(
                ListItem(false), push(new Node(pop())),
                ZeroOrMore(BlankLine()),
                ZeroOrMore(ListItem(false), peek(1).addChild(pop()), ZeroOrMore(BlankLine()))
        );
    }
View Full Code Here

        int start = 0;
        int end = innerSource.indexOf('\u0001', start); // look for boundary markers
        if (end == -1) {
            // if we have just one part simply parse and set
            Context<Node> context = getContext();
            Node innerRoot = parseRawBlock(innerSource).resultValue;
            setContext(context); // we need to save and restore the context since we might be recursing
            return push(tight ? new TightListItemNode(innerRoot) : new LooseListItemNode(innerRoot));
        }

        // ok, we have several parts, so create the root node and attach all part roots
        push(tight ? new TightListItemNode() : new LooseListItemNode());
        while (true) {
            end = innerSource.indexOf('\u0001', start);
            if (end == -1) end = innerSource.length();
            String sourcePart = innerSource.substring(start, end);

            Context<Node> context = getContext();
            Node node = parseRawBlock(sourcePart).resultValue;
            setContext(context);
            peek().addChild(node.getChildren().get(0)); // skip one superfluous level

            if (end == innerSource.length()) return true;
            start = end + 1;
        }
    }
View Full Code Here

        StringVar source = new StringVar();
        return Sequence(
                Line(),
                source.set(pop().getText()),
                ZeroOrMore(ListBlockLine(), source.append(pop().getText())),
                push(new Node(source.get()))
        );
    }
View Full Code Here

        StringVar name = new StringVar();
        return Sequence(
                OneOrMore(Alphanumeric()),
                name.set(match().toLowerCase()) && // compare ignoring case
                        Arrays.binarySearch(HTML_TAGS, name.get()) >= 0 && // make sure its a defined tag
                        push(new Node(name.get()))
        );
    }
View Full Code Here

    //************* INLINES ****************

    Rule Inlines() {
        return Sequence(
                InlineOrIntermediateEndline(), push(new Node(pop())),
                ZeroOrMore(InlineOrIntermediateEndline(), peek(1).addChild(pop())),
                Optional(Endline())
        );
    }
View Full Code Here

TOP

Related Classes of org.pegdown.ast.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.