mirror of
https://github.com/tenrok/BBob.git
synced 2026-06-08 17:22:26 +03:00
feat: add start and end positions of tag nodes (#246)
Closes #134 * feat: Add start and end positions of tag nodes Improves accuracy of row/col error reporting. Now targets the start of the relevant token instead of the end. * Simplify language for TagNode and Token * Update static TagNode.create to ingest setStart() logic improve readability of end pos offset for no attr tags
This commit is contained in:
@@ -185,7 +185,7 @@ function parse(input: string, opts: ParseOptions = {}) {
|
||||
function handleTagStart(token: Token) {
|
||||
flushTagNodes();
|
||||
|
||||
const tagNode = TagNode.create(token.getValue(), {}, []);
|
||||
const tagNode = TagNode.create(token.getValue(), {}, [], { from: token.getStart(), to: token.getEnd() });
|
||||
const isNested = isTokenNested(token);
|
||||
|
||||
tagNodes.push(tagNode);
|
||||
@@ -203,6 +203,10 @@ function parse(input: string, opts: ParseOptions = {}) {
|
||||
* @param {Token} token
|
||||
*/
|
||||
function handleTagEnd(token: Token) {
|
||||
const lastTagNode = nestedNodes.last();
|
||||
if (isTagNode(lastTagNode)) {
|
||||
lastTagNode.setEnd({ from: token.getStart(), to: token.getEnd() });
|
||||
}
|
||||
flushTagNodes();
|
||||
|
||||
const lastNestedNode = nestedNodes.flush();
|
||||
|
||||
Reference in New Issue
Block a user