3

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>

I tried hxremove footer foo.html, but it doesn't output anything.

  • Possible duplicate of How to run hxnormalize on multiple files? – peterh Sep 28 '17 at 11:51
  • 1
    @peterh I don't think the question here as asked is a duplicate, because they're showing an issue when attempting to process a single file. – roaima Sep 28 '17 at 14:13
  • actually, I am the author of both questions and this one here is a follow up I ran into after the other question had been answered – user430 Sep 28 '17 at 14:24
  • @user430 Sorry - it seems I overlooked it. However, there is no more close vote from your question, thus it passed the review process. – peterh Sep 28 '17 at 14:25
2
  1. These commands work from stdin to stdout. You have to use them like hxremove selector <src.html >dst.html.

  2. My tests show they require at least a little bit valid html (<html>, <body> should be therein as usual).

  3. Here you have to give a valid (x)html selector. footer is okay in this case, so it should work.

My example:

t.html:

<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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.