posthtml / posthtml-parser

Parse HTML/XML to PostHTMLTree

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

directives not making it through to parser

curiouslychase opened this issue · comments

I have a directive in my call to posthtml:

posthtml([transformer]).process(
      fs.readFileSync(filename).toString(),
      {
        directives: [{ name: "njk", start: "{{%", end: "%}}" }]
      }
    )

I noticed that the directive doesn't make it through to the parser and found that last here is undefined so the loop returns early. Should the return be a continue? I don't understand the purpose of bufArray here, if it's necessary can someone help me understand what the right way to pass a directive through is?

posthtml-parser/index.js

Lines 49 to 57 in 009fe5a

if (isDirective(directive, name)) {
if (!last) {
results.push(directiveText);
return;
}
last.content || (last.content = []);
last.content.push(directiveText);
}

@chaseadamsio Hi, can you lay out or describe more criteria for reproducing this?

i create test for you description #42