Login  Register

Re: Is AST Document limited to see blocks - level 1,2 only

Posted by ch007m on Apr 09, 2020; 10:52am
URL: https://discuss.asciidoctor.org/Is-AST-Document-limited-to-see-blocks-level-1-2-only-tp7858p7864.html

I observe a strange behavior. If I execute the following code on my document

public class DynamicTable extends Treeprocessor {

    @Override
    public Document process(Document document) {
        processBlock((StructuralNode) document);
        return document;
    }

    private void processBlock(StructuralNode node) {
        System.out.println("==== FindBy \":section\" selector");
        selector = new HashMap<Object, Object>();
        selector.put("context", ":section");
        findBy = node.findBy(selector);
        for (int j = 0; j < findBy.size(); j++) {
            final StructuralNode subNode = findBy.get(j);
            System.out.println("Node content: " + subNode.getContent());
        }

then I get the rendered HTLM content

==== FindBy ":section" selector
Node content: <div class="paragraph">
<p>Let&#8217;s start digging into the <a href="https://docs.ansible.com/">Ansible</a> documentation.</p>
</div>
<div class="paragraph">
...


Can we use `FindBy` method on the AST document objects only and not the HTML rendered ?
Charles Moulliard
Apache Committer / Technologist Evangelist / Blogger / MiddleWare Specialist
Twitter : @cmoulliard