Skip to content

disect dependency not working as expected #8

@joshjung

Description

@joshjung

Hey there, after about 4-5 hours of fighting an issue I discovered that the disect library is not working as one would expect for use with the tokenizer.

Here is my use case:

t.addRule(/^([a-zA-Z0-9\-_]+\s*=\s*)(["'])(\\\2|[^"']+)*?\2$/, 'tKeyValue'); // Matches name='value'
t.addRule(/^[a-zA-Z0-9\-_]+$/, 'tIdentifier'); // Matches name

The line I am attempting to tokenize is (slim template code):

tag#id var1 = 'value1' var2 = 'value2'

For some reason, the disect library starts with the full length string and then halves the index value every single time it attempts another match, so it ends up trying to match the following strings:

tag#id var1 = 'value1' var2 = 'value2'
tag#id var1 = 'valu
tag#id

This does not have the desired result. I've fixed the issue in my fork and will be attempting a merge. However, I am not sure what testing suite is being used and would like to write some tests myself. What should I write them in?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions