HXADDID(1)

πŸ’– HXADDID(1) πŸ’–

okay bestie, welcome to hxaddid β€” part of the HTML-XML-utils crew (that's the HTML-XML-utils manual set, hi πŸ‘‹). she adds IDs to the elements you pick. that's literally her whole personality and she ate.


✨ NAME ✨

hxaddid β€” add IDs to selected elements πŸŽ€


🌸 SYNOPSIS 🌸

hxaddid [ -x ] [--] elem|.class|elem.class [ file-or-URL ]

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: hxaddid copies an HTML or XML file over to standard output, and while she's doing it she sprinkles element IDs onto the elements or classes you asked for. lowkey magic ✨

like, imagine your input is

<p>A paragraph without an ID</p>

and then you run

hxaddid p

and she gives you back

<p id="a-paragraph">A paragraph without an ID</p>

iconic. the paragraph has an identity now πŸ’…

if you specify a class with .class, then IDs only get added to elements that contain that class. and if you specify an element and a class together with elem.class, then IDs only get added to the specified elements that contain the specified class. selective queen πŸ‘‘

now, if two elements would naturally generate the same ID, a number gets tacked onto the ID name (starting with 0) so the IDs stay unique. no dupes, no drama. and heads up β€” IDs are not added to matching elements that already contain an ID. she knows when to leave a girl alone πŸ™ˆ


πŸ’… OPTIONS πŸ’…

here's what she supports:

  • -x β€” use XML conventions: empty elements get written with a slash at the end, like <IMG />. also, this makes the element get matched case-sensitively. so, like, pick a lane and commit bestie.

πŸ‘‘ OPERANDS πŸ‘‘

the following operands are supported:

  • elem β€” the name of the element to select.
  • .class β€” the name of the class to select.
  • elem.class β€” the name of the element that contains the class to select.
  • file-or-URL β€” the name or URL of an HTML or XHTML file.

🌈 EXIT STATUS 🌈

the following exit values are returned:

  • 0 β€” successful completion. we love a happy ending 🫢
  • > 0 β€” an error occurred in the parsing of one of the HTML or XML files. 😭

🧚 ENVIRONMENT 🧚

to use a proxy to retrieve remote files, set the environment variables http_proxy or ftp_proxy. e.g.:

http_proxy="http://localhost:8080/"

go through the proxy, babe, it's fine πŸ“


πŸ’€ BUGS πŸ’€

okay so, real talk, some caveats:

  • she assumes UTF-8 as input. and she doesn't expand character entities. instead, pipe the input through hxunent(1) and asc2xml(1) to convert it to UTF-8. do the pipeline, bestie, it's giving teamwork ✨
  • hxaddid tries first to generate "readable" IDs by forming the ID out of the letters and digits found in the content of the element, and falls back to generating arbitrary IDs if it doesn't find enough. however, the algorithm in this version is primitive and only gives reasonable results for ASCII letters and digits. so like, don't expect miracles for the fancy stuff 😭
  • remote files (specified with a URL) are currently only supported for HTTP. password-protected files or files that depend on HTTP "cookies" are not handled. (you can use tools such as curl(1) or wget(1) to retrieve such files.) we're not doing auth, we're just a girl πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

asc2xml(1), hxprune(1), hxnormalize(1), hxnum(1), hxtoc(1), hxunent(1), xml2asc(1), UTF-8 (RFC 2279)


and that's the whole page, periodt ✨ this one's from the HTML-XML-utils collection, version 7.x, dated 10 Jul 2011. old but she still slays πŸ’–πŸ¦‹πŸŒΈ