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

examples with nested classes, e.g. microformats2 #42

Open
tantek opened this Issue Dec 8, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@tantek
Member

tantek commented Dec 8, 2016

Just saw the lightning talk at #MozAloha - very cool!

Is it possible to write Fathom rules to detect nested class names? Perhaps even with additional CSS Selector constraints?

Would it be possible to add a simple example rule set for parsing data from nested elements with particular class names?

For example, I'd like to write rules like the nested class name rules for microformats2 parsing:

http://microformats.org/wiki/microformats2-parsing#parse_an_element_for_class_microformats

Or at least rules like:
.h-entry .p-name -> title = textContent

Happy to help get something simple working and iterate from there.

@tantek

This comment has been minimized.

Show comment
Hide comment
@tantek

tantek Dec 8, 2016

Member

cc: @mixedpuppy who may have some suggestions for how to do this in Firefox in particular

Member

tantek commented Dec 8, 2016

cc: @mixedpuppy who may have some suggestions for how to do this in Firefox in particular

@erikrose

This comment has been minimized.

Show comment
Hide comment
@erikrose

erikrose Dec 8, 2016

Member

Absolutely. For simple cases, you could just use CSS selectors, like...

const rules = ruleset(
    rule(dom('.h-entry .p-name'), type('title').note(fnode => fnode.element.textContent))
);

Soon I plan to add contains() and matching() to the left-hand side of rules that will make it easier to express typed containment (a "foo"-typed node within a "title"-typed node) and arbitrary predicates.

Member

erikrose commented Dec 8, 2016

Absolutely. For simple cases, you could just use CSS selectors, like...

const rules = ruleset(
    rule(dom('.h-entry .p-name'), type('title').note(fnode => fnode.element.textContent))
);

Soon I plan to add contains() and matching() to the left-hand side of rules that will make it easier to express typed containment (a "foo"-typed node within a "title"-typed node) and arbitrary predicates.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost May 26, 2018

Yes, contains() and matching() would be a very powerful addition indeed. Do you think you could maybe roughly outline how would you approach the implementation of those? I take you will probably not add any new features anymore given the project is not very active?

ghost commented May 26, 2018

Yes, contains() and matching() would be a very powerful addition indeed. Do you think you could maybe roughly outline how would you approach the implementation of those? I take you will probably not add any new features anymore given the project is not very active?

@erikrose

This comment has been minimized.

Show comment
Hide comment
@erikrose

erikrose May 29, 2018

Member

Probably just the naive way to begin with, then optimizing as the need proves itself. Most of the dev work is happening in https://github.com/erikrose/fathom-fox/ at the moment: integrating Fathom development tools into Firefox so we can write rulesets faster and more easily. Then I have some crazy ideas for Fathom 3, which will bring contains, matching, and, indeed, arbitrary predicates.

Member

erikrose commented May 29, 2018

Probably just the naive way to begin with, then optimizing as the need proves itself. Most of the dev work is happening in https://github.com/erikrose/fathom-fox/ at the moment: integrating Fathom development tools into Firefox so we can write rulesets faster and more easily. Then I have some crazy ideas for Fathom 3, which will bring contains, matching, and, indeed, arbitrary predicates.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Jun 1, 2018

Thanks for your reply, Erik. And many thanks for such a cool piece of software! :)

ghost commented Jun 1, 2018

Thanks for your reply, Erik. And many thanks for such a cool piece of software! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment