Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] Add config option to include structural/semantic elements #66

Open
eoghanmurray opened this issue Apr 25, 2023 · 7 comments

Comments

@eoghanmurray
Copy link

So I'm not sure if this is out of scope for this project.

I'm not so much interested as the shortest selector, as the most meaningful one.

From that point of view, any of the following tags are interesting:
https://www.w3schools.com/html/html5_semantic_elements.asp

I'd like those to be always included in the selector if they are present in the ancestor list.

I guess these would have to be qualified if they are not unique, so article:nth-of-type(2).

Does this request make any sense or is it a different project?

@eoghanmurray
Copy link
Author

I guess a similar option to always include an ancestor which has an id might also be worthwhile from a 'meaningful' point of view.

@antonmedv
Copy link
Owner

I think it’s doable

@eoghanmurray
Copy link
Author

eoghanmurray commented Apr 27, 2023

How about a separate entry point which may call finder multiple times.

So recursively do

target.closest('article,main,section....)`

And then chain together multiple calls to finder using each such ancestor as the root

?

I can code this up unless you've an easier way of achieving it in the current .parentNode walk.

Probably should be separate config options for addStructure and addIds

@antonmedv
Copy link
Owner

We can just give different penalties depending on if it is a semantic tag or not.

@eoghanmurray
Copy link
Author

eoghanmurray commented May 4, 2023

I still haven't wrapped my head around the penalty system ... does it completely take precedence over length-of-string?

@antonmedv
Copy link
Owner

does it completely take precedence over length-of-string

Yes. As the goal not only short, but robust.

@eoghanmurray
Copy link
Author

I'm not sure if the penalties alone will suffice; I'm thinking of this proposal as being a lot more verbose, so that it would have to look right back in the hierarchy to find those significant tag names.
As I understand it the penalty system only operates on the current level and cannot be used to 'pop out' of the hierarchy to continue evaluation with more ancestors?

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

No branches or pull requests

2 participants