I try to remove a footer section in multiple html files. For simplicity I started with just one file. The file contains:
<footer id="footer"> ... </footer>
hxremove footer foo.html, but it doesn't output anything.
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.Sign up to join this community
These commands work from stdin to stdout. You have to use them like
hxremove selector <src.html >dst.html.
My tests show they require at least a little bit valid html (
<body> should be therein as usual).
Here you have to give a valid (x)html selector.
footer is okay in this case, so it should work.
<html> <body> <a>cica</a> <p>cica</p> <p>cica</p> </body> </html>
Then the command
hxremove 'p' <t.html outputs correctly
<html> <body> <a>cica</a> </body> </html>
So, it can be made working, only you have to play a little bit more with it.
You can use the
hxnormalize tool in the same software package to ensure, how things are looking in the eyes of the xhtml processor: the command
hxnormalize <t.html outputs this:
<html> <body> <p><a>cica</a> <p>cica <p>cica
The seemingly unneeded empty lines are correct behavior - the selector remove only the html part, and not the text (this time, the whitespaces) between them.