tagQuery does not allow ":" to exist in tag type when searching

Open
#356 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
r
Domain
tooling

Research direction

Start at R/selector.R line 44 and reproduce the reported x_q$find("w:t") failure from the issue body. Trace how tagQuery handles the colon, then verify that namespaced tags such as w:t can be searched while the existing selector behavior remains intact.

Written by the indexing model from the issue text.

Description

I am working on some ooxml to support processing of {gt} into word outputs and I was hoping to use tagQuery to allow me to sort through the tags and make edits. tag types are prepended for docx outputs with w:. The current logic blocks me from using : anywhere in a tag because it does a simple search for : existing. Could there be a caveat in this if statement to check whether that call matches directly any tag types or something?

https://github.com/rstudio/htmltools/blob/39b3f1f6a4abef8acebc407d506d239d871d6a03/R/selector.R#L44

ie given the ooxml: <w:p><w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space="default">Test this</w:t></w:r></w:p>

if I want to access the text tag (w:t), the find (or any other cssSelector arg) complains about ::

library(htmltools)

## contructed html tag of ooxml containing a paragraph saying "test string"
x <- structure(list(name = "w:p", attribs = list(), children = list(
    structure("<w:pPr></w:pPr><w:r><w:rPr></w:rPr><w:t xml:space=\"default\">test string</w:t></w:r>", html = TRUE, class = c("html", 
    "character")))), class = "shiny.tag")
x_q <- tagQuery(x)
x_q$find("w:t")
Dominant language
R
Stars
225
Forks
73
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rstudio/htmltools

All issues in rstudio/htmltools

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.