Skip to content

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

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

Closed
tantek opened this issue Dec 8, 2016 · 5 comments
Closed

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

tantek opened this issue Dec 8, 2016 · 5 comments

Comments

@tantek
Copy link
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
Copy link
Member Author

tantek commented Dec 8, 2016

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

@erikrose
Copy link
Contributor

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
Copy link

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
Copy link
Contributor

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
Copy link

ghost commented Jun 1, 2018

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

erikrose pushed a commit to erikrose/fathom that referenced this issue Mar 24, 2020
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