Skip to content

Use Markdown and add hover for attr/attr-value. - #65

Merged
Pine (octref) merged 3 commits into
masterfrom
pine/html-custom-data
Jul 27, 2019
Merged

Pine (octref) merged 3 commits into
masterfrom
pine/html-custom-data

Conversation

@octref

Copy link
Copy Markdown
Contributor

Also, the parser is updated to return attr / attr-value locations.

Comment thread src/parser/htmlParser.ts Outdated
attr: string;
start: number;
end: number;
value: AttributeValueWithLocation | null;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTML documents can be very large, and so the number of nodes in a HTML AST.
When designing the AST, the focus was on keeping the size of each node as small as possible. That's why it doesn't keep all the offsets and originally also not the value. The idea is to rescan when that information is required.
That we keep the value should be reconsidered as for the workspace symbols we don't really need them in the AST (again, very easy to do with the scanner)

Comment thread src/services/htmlHover.ts
if (tagRange) {
return getTagHover(node.tag, tagRange, true);
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done with a single scan start from node.start.

  • scan as long as we found a token scanner.getTokenEnd() >= offset && offset <= scanner.getTokenEnd()
  • if token is tag, attrname or attr value, create the corresponding hover
  • while scanning, remember the last seen attribute name

@octref
Pine (octref) merged commit b5ac102 into master Jul 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

markdown descriptions Provide tag attribute / attribute value hover

2 participants