easy-scraper icon indicating copy to clipboard operation
easy-scraper copied to clipboard

Error when parsing templates with tables in them

Open zicklag opened this issue 5 years ago • 1 comments

Hey there, I think this is a really great idea, good job!

I'm having an issue when I use HTML table tags such as tr, td, etc in a template. It seems to require that I have full valid HTML for a table in the template, instead of treating it like the other tags, where ... is allowed between siblings, the parent tags ( <table><tbody> ) aren't required, etc. I get the errors while compiling the pattern. Here are some examples of failing patterns:

<tr>{{test:*}}</tr>

This fails with: Found special tag while closing generic tag.

The reason seems to be because I don't have the surrounding table tags. This works:

<table><tbody>
          <tr><td>{{test}}</td></tr>
</tbody></table>

This is almost good enough for my use-case, except it won't allow the ... for non-adjacent siblings either:

<table><tbody>
          <tr><td>Option 1:</td><td>{{option1}}</td></tr>
          ...
          <tr><td>Option 2:</td><td>{{option2}}</td></tr>
</tbody></table>

This fails with: Non-space table text.

zicklag avatar Mar 25 '20 02:03 zicklag

I found this in the logs which might be part of the reason for the ... issue.

Debug [html5ever::tree_builder]: processing TagToken(Tag { kind: StartTag, name: Atom(\'tr\' type=static), self_closing: false, attrs: [] }) in insertion mode InTableText
Warning [html5ever::tree_builder]: foster parenting not implemented
Debug [html5ever::tree_builder]: processing CharacterTokens(NotSplit, Tendril<UTF8>(inline: \"\\n\")) in insertion mode InBody
Warning [html5ever::tree_builder]: foster parenting not implemented
Debug [html5ever::tree_builder]: processing CharacterTokens(NotSplit, Tendril<UTF8>(inline: \"  ...\")) in insertion mode InBody
Warning [html5ever::tree_builder]: foster parenting not implemented
Debug [html5ever::tree_builder]: processing CharacterTokens(NotSplit, Tendril<UTF8>(inline: \"\\n\")) in insertion mode InBody
Warning [html5ever::tree_builder]: foster parenting not implemented
Debug [html5ever::tree_builder]: processing CharacterTokens(NotSplit, Tendril<UTF8>(inline: \"  \")) in insertion mode InBody
Debug [html5ever::tree_builder]: processing TagToken(Tag { kind: StartTag, name: Atom(\'tr\' type=static), self_closing: false, attrs: [] }) in insertion mode InTableBody
Debug [html5ever::tokenizer]: processing in state Data

zicklag avatar Mar 25 '20 03:03 zicklag