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

Add support for more selectors #28

Merged
merged 3 commits into from
Mar 17, 2017

Conversation

antiagainst
Copy link
Contributor

  1. Add support for getting CSS attribute value.

This commit add a new key 'attr' in dashing.json selector objects.
If "attr": "attribute" exists, dashing will get the value of the
"attribute" of the current selected node and use it instead of the
node text as the base name for transforms.

E.g.,

<a id="wow">link</a> together with "attr": "id" will get "wow"
instead of "link".

  1. Add support for requiring text content when matching.

With this commit, we can further require the node selected with
CSS selector to match certain text regexp.

E.g.,

<h2>This is a title</h2> with "requiretext": "^This is" will
considered as a match, while with "requiretext": "^No", it is not.

  1. Add support for multiple transforms of the same CSS selector.
    With this commit, we can supply multiple transforms for the same
    CSS selector. It enables treating the same CSS selector with
    different texts separately.

E.g.,

<h2>Chapter X</h2>
<h2>Section Y</h2>

with

"h2": [
  {
    "requiretext": "^Chapter",
    "Type": "Module"
  },
  {
    "requiretext": "^Section",
    "Type": "Section"
  }
]

Will treat "X" as Module and "Y" as "Section".

This commit add a new key 'attr' in dashing.json selector objects.
If "attr": "attribute" exists, dashing will get the value of the
"attribute" of the current selected node and use it instead of the
node text as the base name for transforms.

E.g.,

<a id="wow">link</a> together with "attr": "id" will get "wow"
instead of "link".
With this commit, we can further require the node selected with
CSS selector to match certain text regexp.

E.g.,

<h2>This is a title</h2> with "requiretext": "^This is" will
considered as a match, while with "requiretext": "^No", it is not.
With this commit, we can supply multiple transforms for the same
CSS selector. It enables treating the same CSS selector with
different texts separately.

E.g.,

<h2>Chapter X</h2>
<h2>Section Y</h2>

with

"h2": [
  {
    "requiretext": "^Chapter",
    "Type": "Module"
  },
  {
    "requiretext": "^Section",
    "Type": "Section"
  }
]

Will treat "X" as Module and "Y" as "Section".
@antiagainst
Copy link
Contributor Author

These changes are used to generate the Vulkan docset: Kapeli/Dash-User-Contributions#1238.

The dashing.json is: https://github.com/antiagainst/dashing/blob/vulkan/examples/vulkan/dashing.json

@technosophos
Copy link
Owner

Thank you! I'm just not catching up on a backlog of PRs from across my projects. I appreciate your patch and am sorry it took so long.

@technosophos technosophos merged commit 7fb99cb into technosophos:master Mar 17, 2017
@antiagainst antiagainst deleted the more-selectors branch March 17, 2017 15:47
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

Successfully merging this pull request may close these issues.

2 participants