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 tagQuery(tags) for complex css selections and alterations #208

Merged
merged 102 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
85f9fbc
Add mutate tags for a generic S3 style / pass by value implementation
schloerke Mar 31, 2021
cf679af
Delete mutate_tags.R as a tag_env approach is going to be used
schloerke Mar 31, 2021
f4056b7
Create selector.R
schloerke Mar 31, 2021
af34b85
Create tag_env.R
schloerke Mar 31, 2021
30519db
Temp add debug_message() into other methods
schloerke Mar 31, 2021
bdff8e2
Update tag_env.R
schloerke Mar 31, 2021
37ab14c
Fix documentation issues with roxygen2
schloerke Apr 1, 2021
f1e7ab1
Only update the signature of `flattenTags()`, not make a different re…
schloerke Apr 2, 2021
7feb3d0
Use fastmap::fastmap() to avoid a constant small mem leak
schloerke Apr 2, 2021
1107cf6
Cleanup of code and docs
schloerke Apr 2, 2021
456ebb1
Fix dev_check
schloerke Apr 2, 2021
e40de90
Rename `tag_graph_walk_*()` to `selected_walk_*()`
schloerke Apr 2, 2021
972d7b0
Use `tag_env$envir_key` to avoid constant calling of `format.default(…
schloerke Apr 2, 2021
1a89ad8
Test selector. Remove :text functionality
schloerke Apr 2, 2021
713e110
Remove debug_message()
schloerke Apr 2, 2021
a0159c0
make fastmap a imported package (from suggested)
schloerke Apr 2, 2021
35dae9c
fix typo bug
schloerke Apr 2, 2021
1dbcf6d
Make a `flattenTagAttribs(attribs)` function
schloerke Apr 2, 2021
ccf06e8
Similar to `$root()` and `$root_as_tags()` now `$get_selected()` is `…
schloerke Apr 2, 2021
c836692
Use `faststack()` to keep items in order. `fastmap()` is only good fo…
schloerke Apr 2, 2021
12af136
document
schloerke Apr 2, 2021
010df91
Create first pass of tests for `tag_graph()`
schloerke Apr 2, 2021
8665481
Fix dev check
schloerke Apr 2, 2021
a3efae3
Update tag_env.R
schloerke Apr 5, 2021
1cfd738
Add support for tagLists in addition to tags for `tag_graph()`
schloerke Apr 5, 2021
f5783c3
Add support for internal method of `get_selected()` vs `manually_sele…
schloerke Apr 6, 2021
c7bcbd2
Update matching logic to be allowed to pre-empt
schloerke Apr 6, 2021
14a97e1
Add `$has_class(class)`, `$toggle_class(class)`, and `$remove_class(c…
schloerke Apr 6, 2021
a236779
Add `$has_attr()`, `$remove_attrs()`, and `$empty_attrs()`
schloerke Apr 6, 2021
d72e2fe
Consolidate `$graph_as_tags()` and `$selected_as_tags()` to `$as_tags…
schloerke Apr 6, 2021
0a98588
Support `>` css selector
schloerke Apr 7, 2021
2943dc0
When appending/prepending/emptying elements, allow for the root to be…
schloerke Apr 7, 2021
d01408a
document
schloerke Apr 7, 2021
e9d323b
Use sub/gsub in str_replace/_all
schloerke Apr 7, 2021
fa829f4
Also use str_detect() from https://github.com/wch/staticimports/blob/…
schloerke Apr 7, 2021
1fe0c30
Force function value in generator method
schloerke Apr 7, 2021
d69cf58
Fix bug with updated behavior in str_remove. Add support for fixed re…
schloerke Apr 7, 2021
0d9a8fc
Merge branch 'mutate_tags' of https://github.com/rstudio/htmltools in…
schloerke Apr 7, 2021
3ead65d
Do not use `stopifnot()` (speed)
schloerke Apr 7, 2021
3b5604f
Use `walk2(x,y,f)` over `Map()` (speed)
schloerke Apr 7, 2021
62defea
When converting an env to a list, convert all names
schloerke Apr 7, 2021
dcb8729
No need for func wrapper
schloerke Apr 7, 2021
881dc0e
Require dev version of rlang
schloerke Apr 8, 2021
90fba73
Add a Rmd document exploring different unique stack implementations
schloerke Apr 8, 2021
7273416
Use new hybrid stack (`unique_envir_stack()`)
schloerke Apr 8, 2021
3392de6
Update tag_env.R
schloerke Apr 8, 2021
081521d
Fix bug in `uni_stack()`. Run output
schloerke Apr 8, 2021
c2d0ffe
Restructure selector list to have the child selector within the match…
schloerke Apr 8, 2021
b20d649
Remove single descendant finding code
schloerke Apr 8, 2021
59746a5
Remove outdated test
schloerke Apr 8, 2021
8cab349
Update tag_env.R
schloerke Apr 9, 2021
4973b76
to upper all the var names :expressionless:
schloerke Apr 9, 2021
2a461c2
Doc changes for `tag graph` to `tag query`. Change `$graph()` to `$ro…
schloerke Apr 9, 2021
72cdd3b
docs
schloerke Apr 9, 2021
30136af
Yoda speak the function names for easier searching
schloerke Apr 9, 2021
45eb5cc
Implement `$after(...)`, `$before(...)`, `$replaceWith(...)`, and `$r…
schloerke Apr 9, 2021
95f67b7
Add ORCID info
schloerke Apr 9, 2021
ea8e151
Support non tag elements. Add some more docs. Restrict what can be us…
schloerke Apr 9, 2021
ed7fc8c
Remove dead logic check
schloerke Apr 12, 2021
8517a2e
Update docs order
schloerke Apr 12, 2021
ea22747
Add flattenTagsRaw comment
schloerke Apr 12, 2021
da89bbb
Add `[[i]]` in between each selected item when printed. Matches list …
schloerke Apr 12, 2021
b2dbb35
Try to register (shiny) devmode options at the init of tagQuery(). Wa…
schloerke Apr 12, 2021
a146a90
Update comment
schloerke Apr 12, 2021
92a5fe8
Revert "Try to register (shiny) devmode options at the init of tagQue…
schloerke Apr 12, 2021
74b4255
Allow `tagQuery()` objects to return tag query objects with pre-set s…
schloerke Apr 12, 2021
0de686b
rename tag_env.R -> tag_query.R
schloerke Apr 12, 2021
3e11a80
document
schloerke Apr 12, 2021
b87e66e
Add `$closest(cssSelector)` support
schloerke Apr 12, 2021
78ba6de
Better line wrapping on docs for better diffs
schloerke Apr 12, 2021
a2ba614
Apply suggestions from code review
schloerke Apr 13, 2021
f137acc
Remove unused function
schloerke Apr 13, 2021
d3b8f9f
Change `envirMap$set(env, value)` to `envirMap$add(env)`
schloerke Apr 13, 2021
ee1f245
Throw if a tagQuery object is sent to `asTagEnv(x)`; Unnest if statem…
schloerke Apr 13, 2021
8cde368
No need to unname tag env children
schloerke Apr 13, 2021
2db4fab
Make sure `tagEnvToTags(x)` starts with a tag environment
schloerke Apr 13, 2021
4a44370
Allow for `tagQuery()` objects to share the same tagEnvs with other `…
schloerke Apr 13, 2021
f2e6a46
Docs; Rename `selected` to `selected_` in `tagQuery_()`; Stop if `set…
schloerke Apr 13, 2021
0f625da
When unlisting info, do not use names
schloerke Apr 13, 2021
d3c31cc
Only set the root children that are tag envs
schloerke Apr 13, 2021
28183fd
Allow other taq query or tag envs to init a tag query object
schloerke Apr 14, 2021
00436be
Formatting
schloerke Apr 14, 2021
e0a581d
Use unique list
schloerke Apr 14, 2021
475ec37
Remove unnecessary wrapper function
schloerke Apr 14, 2021
8242d96
cssSelectorToSelector comments
schloerke Apr 14, 2021
a2e6b56
Merge branch 'mutate_tags' of https://github.com/rstudio/htmltools in…
schloerke Apr 14, 2021
38b4cc5
Change name to avoid name conflict. Add comment about `fixed` usage.
schloerke Apr 14, 2021
489ff4c
Use `oldClass(x)` and remove explicit "environment" class as S3 is no…
schloerke Apr 14, 2021
0d65b12
Use `as.character(x)` to convert an list to a character vector
schloerke Apr 14, 2021
cb4e1e1
`tagEnvToTags(x)` comments
schloerke Apr 14, 2021
b8ca22f
Remove `fastmap()$remove(key)` call to speed up function. Mention lob…
schloerke Apr 14, 2021
ca47d5e
Remove `tagEnvExplain()` in favor of `lobstr::tree(x, show_environmen…
schloerke Apr 14, 2021
5696b55
Implement `$parents()` using depth first search
schloerke Apr 14, 2021
5d982d1
Missing paren
schloerke Apr 14, 2021
97c7cc0
Add comment to make a GH issue if `tagInsertChildren()` should be exp…
schloerke Apr 14, 2021
dc56567
`$closest(NULL)` should return `$selected()`
schloerke Apr 14, 2021
355db78
can not call `as.character(list2(...))` as `...` may contain vectors.…
schloerke Apr 14, 2021
fdb8a32
When traversing the parents, start with the parents
schloerke Apr 14, 2021
eceaa26
Update test-tag-query.R
schloerke Apr 14, 2021
d58f43c
Use h1 tags in news
schloerke Apr 15, 2021
4f27951
Add news entry
schloerke Apr 15, 2021
d46d5d7
Update title
schloerke Apr 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Version: 0.5.1.9000
Authors@R: c(
person("Joe", "Cheng", role = "aut", email = "[email protected]"),
person("Carson", "Sievert", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0002-4958-2844")),
person("Winston", "Chang", role = "aut", email = "[email protected]"),
person("Barret", "Schloerke", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0001-9986-114X")),
person("Winston", "Chang", role = "aut", email = "[email protected]", comment = c(ORCID = "0000-0002-1576-2126")),
person("Yihui", "Xie", role = "aut", email = "[email protected]"),
person("Jeff", "Allen", role = "aut", email = "[email protected]"),
person(family = "RStudio", role = "cph")
Expand All @@ -18,14 +19,17 @@ Imports:
digest,
grDevices,
base64enc,
rlang
rlang,
fastmap
Suggests:
markdown,
testthat,
withr,
Cairo,
ragg,
shiny
Remotes:
r-lib/rlang
Enhances: knitr
License: GPL (>= 2)
URL: https://github.com/rstudio/htmltools
Expand All @@ -39,7 +43,9 @@ Collate:
'html_print.R'
'images.R'
'known_tags.R'
'selector.R'
'shim.R'
'tag_query.R'
'utils.R'
'tags.R'
'template.R'
17 changes: 17 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,23 +1,36 @@
# Generated by roxygen2: do not edit by hand

S3method(as.character,html)
S3method(as.character,htmltools.tag.env)
S3method(as.character,htmltools.tag.query)
S3method(as.character,shiny.tag)
S3method(as.character,shiny.tag.list)
S3method(as.tags,character)
S3method(as.tags,default)
S3method(as.tags,html)
S3method(as.tags,html_dependency)
S3method(as.tags,htmltools.tag.env)
S3method(as.tags,htmltools.tag.query)
S3method(as.tags,list)
S3method(as.tags,shiny.tag)
S3method(as.tags,shiny.tag.function)
S3method(as.tags,shiny.tag.list)
S3method(format,html)
S3method(format,htmltools.selector)
S3method(format,htmltools.selector.list)
S3method(format,htmltools.tag.env)
S3method(format,htmltools.tag.query)
S3method(format,shiny.tag)
S3method(format,shiny.tag.list)
S3method(print,html)
S3method(print,html_dependency)
S3method(print,htmltools.selector)
S3method(print,htmltools.selector.list)
S3method(print,htmltools.tag.env)
S3method(print,htmltools.tag.query)
S3method(print,shiny.tag)
S3method(print,shiny.tag.list)
S3method(str,htmltools.tag.env)
export("htmlDependencies<-")
export(HTML)
export(a)
Expand Down Expand Up @@ -84,6 +97,7 @@ export(tagFunction)
export(tagGetAttribute)
export(tagHasAttribute)
export(tagList)
export(tagQuery)
export(tagSetChildren)
export(tags)
export(takeSingletons)
Expand All @@ -93,4 +107,7 @@ export(withTags)
import(digest)
import(rlang)
import(utils)
importFrom(fastmap,fastmap)
importFrom(fastmap,faststack)
importFrom(rlang,sexp_address)
useDynLib(htmltools, .registration = TRUE)
51 changes: 25 additions & 26 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
htmltools 0.5.1.9000
--------------------------------------------------------------------------------
# htmltools (development version)

## New Features & Improvements

* Added `tagQuery(tags)`. A tag query object implements many popular features of jQuery. Similar to jQuery, tag query objects can find internal html using CSS selections. Given a selection (which defaults to the original `tags`), many alterations may be performed before converting the tag query object back to tag objects. (#208)

## Bug Fixes

* Closed #197: Fixed rendering of boolean attributes in <script> tags rendered via renderDependencies() (#197, thanks @atusy).

htmltools 0.5.1.1
--------------------------------------------------------------------------------

# htmltools 0.5.1.1

* Added shiny as a suggested package.


htmltools 0.5.1
--------------------------------------------------------------------------------
# htmltools 0.5.1

## New Features & Improvements

Expand All @@ -35,8 +39,7 @@ htmltools 0.5.1
* `print(as.tags(x))` no longer results in error when `x` is a generic `list()` of tag-like objects. (#181)


htmltools 0.5.0
--------------------------------------------------------------------------------
# htmltools 0.5.0

* `tags` is now generated by a script which collects all
[HTML](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) and
Expand Down Expand Up @@ -74,8 +77,8 @@ htmltools 0.5.0
* The `.noWS` parameter for suppressing whitespace can now take an `"inside"`
value (equivalent to `c("after-start", "before-end")`). (#163)

htmltools 0.4.0
--------------------------------------------------------------------------------

# htmltools 0.4.0

* Fixed #128: Added support for trailing commas in tagLists and the predefined
tags. (#135)
Expand Down Expand Up @@ -110,8 +113,9 @@ htmltools 0.4.0
* Stopped extra carriage returns from being inserted by `save_html` on Windows.
(#137)

htmltools 0.3.6
--------------------------------------------------------------------------------


# htmltools 0.3.6

* `validateCssUnit()` now accepts viewport units (vw, vh, vmin, vmax). (#56)

Expand All @@ -123,8 +127,8 @@ htmltools 0.3.6
* Fixed #69: On Windows, `renderDocument()` did not mark output as UTF-8 if the
head was UTF-8 but body was ASCII. (#71)

htmltools 0.3.5
--------------------------------------------------------------------------------

# htmltools 0.3.5

* `as.character` now returns a character vector with no other attributes.
Previously it returned a character vector of class 'html'. (#31, #41)
Expand Down Expand Up @@ -152,17 +156,16 @@ htmltools 0.3.5
* Performance improvement rendering tags, by switching from `readLines` to
`readChar`.

htmltools 0.3
--------------------------------------------------------------------------------

# htmltools 0.3

* Add `css` function for conveniently forming CSS declaration strings.

* Add template support, with the `htmlTemplate()`, `renderDocument()`, and
`suppressDependencies()` functions.


htmltools 0.2.9
--------------------------------------------------------------------------------
# htmltools 0.2.9

* Add check that `htmlDependency()` isn't called with an absolute path when a
binary package is built. (#22)
Expand All @@ -173,30 +176,26 @@ htmltools 0.2.9
* Add `tagGetAttribute()` and `tagHasAttribute()` functions.


htmltools 0.2.7
--------------------------------------------------------------------------------
# htmltools 0.2.7

* Add "append" parameter to attachDependencies, to allow adding dependencies,
instead of replacing them.


htmltools 0.2.6
--------------------------------------------------------------------------------
# htmltools 0.2.6

* Add "attachment" parameter to htmlDependency, which can be used to allow any
file in the dependency directory to be available via URL at runtime.


htmltools 0.2.5
--------------------------------------------------------------------------------
# htmltools 0.2.5

* Explicit library(htmltools) is no longer required for tags to be rendered in
knitr/rmarkdown documents.

* Added "viewer" parameter to html_print.


htmltools 0.2.4
--------------------------------------------------------------------------------
# htmltools 0.2.4

Initial release
Loading