question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Various HTML parser errors

See original GitHub issue

I’m submitting a bug report

  • Extension Version: 1.0.4

Please tell us about your environment:

  • Operating System: OSX 10.13.6

  • Visual studio code version: 1.36.1

Current behavior:

Three parser bugs I encountered (I added extra logging here for the detailed trace)

1. Parser Error: Unconsumed token } at column 10 in expression

image
Possible fixed found

https://github.com/aurelia/vscode-extension/blob/095e4942d56a2ba7640fbc6b21fb8853fca90242/src/server/FileParser/Parsers/AureliaHtmlParser.ts#L93

// Add greedy matcher
- const interpolationRegex = /\$\{(.*)\}/g;
+ const interpolationRegex = /\$\{(.*?)\}/g;

2. Parser Error: Unconsumed token of at column 7 in expression [button of buttons]"

image
Possible fixed found

When I dug into it, I found the cause to be in aurelia-bindings. (So may have to report an issue over there) More specifically

This line was called when parsing 'of` https://github.com/aurelia/binding/blob/7ef619343781189fd2913de866901fd5767fd6f9/src/parser.js#L388

My ‘fix’ was then to add https://github.com/aurelia/binding/blob/7ef619343781189fd2913de866901fd5767fd6f9/src/parser.js#L683

KeywordLookup.in = T$InKeyword;
+ KeywordLookup.of = T$InKeyword;

Obviously T$InKeyword; should be changed to sth else, but I don’t know how that part worked

Plus https://github.com/aurelia/binding/blob/7ef619343781189fd2913de866901fd5767fd6f9/src/parser.js#L701

- '<=', '>=', 'in', 'instanceof', '+', '-', 'typeof', 'void', '*', '%', '/', '=', '!'
+ '<=', '>=', 'in', 'of', 'instanceof', '+', '-', 'typeof', 'void', '*', '%', '/', '=', '!'

3. Parser Error: Unterminated template at column 41 in expression

image
No fixed found yet

Steps to reproduce:

Have an .html file with following minimal content

<template>
  <!-- 1. -->
  <a href="/some/route#?projectIds=${project_id}">${projectsMap[project_id].title}</a>


  <!-- 2. -->
  <span repeat.for="button of buttons"></span>

  <!-- 3. -->
  <p innerhtml="${`workflow.list.details.status.${workflow.status}` | localize}"></p>

</template>

Expected/desired behavior:

  • What is the expected behavior? No parsing errors

I can/will submit PRs if I find the time, for now this issue is to track the bugs

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
erikliebencommented, Aug 1, 2019

This is not for syntax highlighting, but for the minimal version of auto complete that is in the current version behind the feature toggle. It’s probably best to drop this as a whole and replace it by the future AST logic.

The syntax highlighting stuff is here: https://github.com/aurelia/vscode-extension/blob/master/syntaxes/html.json

Downside of it is that it needs to be updated each time the vscode team modifies theirs; this one is based upon it, but contains extensions for aurelia items. So it will break from time to time. And it will only work with themes that have the scopes for aurelia tags defined, which are they ones we currently maintain as well.

If we need to perform the scan for the AST for completions/hover/ etc, then we might as well drop the html.json and use the https://code.visualstudio.com/api/references/vscode-api#TextEditor.setDecorations API to color the Aurelia related items based upon that information. Then it will work in each and every template, or we can allow users to turn coloring off or do customize it from the config, instead of need to build a custom theme.

I will try to put more sequential hours in my weekly schedule, these scattered hours here and there in the week aren’t working to produce something, I am mainly trying to figure out where I left off last time. Then I can create a vNext branch and revamp the extension with the latest things possible and we are able hopefully have a more smooth way of adding the AST engine when it’s ready.

1reaction
AlbertoMonteirocommented, Aug 28, 2020

Thanks for pointing out the scripts @hiaux0 , I’ve changed in my extension node_modules and auto completion on html is working now!

Read more comments on GitHub >

github_iconTop Results From Across the Web

8.2 Parsing HTML documents — HTML5 - W3C
Parse errors are only errors with the syntax of HTML. In addition to checking for parse errors, conformance checkers will also verify that...
Read more >
Common CSS Parser Errors (Parsing Errors Found)
An easy way to fix this is to paste the CSS code into an editor such as Notepad++ and do 2 find/replaces: Replace...
Read more >
13.2 Parsing HTML documents - HTML Standard - WhatWG
Parse errors are only errors with the syntax of HTML. In addition to checking for parse errors, conformance checkers will also verify that...
Read more >
beautifulsoup html.parser error - python - Stack Overflow
I am trying to use BeautifulSoup to parse HTML ...
Read more >
Resolving Errors Related to Invalid HTML Code
Some errors, however, can be serious enough to cause Test Studio's parser to crash. If so, you'll see the above warning message. The...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found