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

Update HTML Nodes / Attributes #54

Open
Gerst20051 opened this issue Aug 29, 2022 · 1 comment
Open

Update HTML Nodes / Attributes #54

Gerst20051 opened this issue Aug 29, 2022 · 1 comment

Comments

@Gerst20051
Copy link

Gerst20051 commented Aug 29, 2022

I would like to do something like the following operations on an HTML file. Can you think of a way to do this?

[$]> echo "$(htmlq ".html.head.title = \"React App Title\"" $react_project_dir/index.html)" > $react_project_dir/index.html

[$]> echo "$(htmlq ".html.head.meta[name=description].content = \"React App Description\"" $react_project_dir/index.html)" > $react_project_dir/index.html

Current Options:

  1. cheerio
  2. himalaya
  3. jsdom
  4. xmltodict
  5. yq/xq

Similar Discussions:

I was able to do the following withyq/xq but it converts HTML to XML.

[$]> xq -x '.html.head.title = "Updated Title" | (.html.head.meta[] | select(."@name" == "description") | ."@content") |= "Updated Description"' index.html

@vendethiel
Copy link

vendethiel commented Dec 20, 2023

Also interested in this use case. Being able to update a node, statically or via a command.

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