HXINCL(1)

πŸ’– HXINCL(1) β€” bestie edition πŸ’–

okay so this is hxincl, part of the HTML-XML-utils crew, and it's literally the girl who expands included HTML or XML files. no cap. she reads your file, finds the little include comments, and slays them into actual content. πŸ¦‹


✨ SYNOPSIS ✨

hxincl [ -x ] [ -f ] [ -s name=subst ] [ -s name=subst ]...  [ -b base ]
[ file-or-URL ]

hxincl -M target [ -s name=subst ] [ -s name=subst ]...  [ -b base ] [
-G ] [ file-or-URL ]

🌸 DESCRIPTION 🌸

okay so when you don't pass -M, hxincl copies an HTML or XML file to standard output, but bestie… she's looking. πŸ‘€ She's hunting for comments with a certain structure, and when she finds one, she swaps it out for the file named in that directive's attribute. Like:

...<!-- include "foo.html" -->...

gets replaced by the whole entire content of foo.html. iconic behavior tbh.

But she doesn't just dump it in there all naked β€” no ma'am. The comment gets replaced by

<!-- begin-include "foo.html" -->

before the included text, and

<!-- end-include "foo.html" -->

after it. why? because those comments mean you can run hxincl on the resulting file again to update the inclusions. it's giving main character energy with a return ticket. πŸ’…

Single quotes are allowed instead of double quotes, bestie. and if the file name has no spaces in it, you can just… drop the quotes entirely. no cap.

Now β€” with -M, she switches it up completely. hxincl outputs a line of dependencies that's suitable for slipping into a Makefile. The target is the target of the Makefile rule, and hxincl will list after the ':' all the files that are included, recursively. so like, the result of

hxincl -M myfile.html inputfile

might be

myfile.html: foo.html bar.html

periodt. πŸ”₯


✨ OPTIONS ✨

here's the menu, bestie, and yes she has range:

  • -x β€” Use XML conventions: empty elements are written with a slash at the end, like <IMG />. the little self-closing slash… she's cute, she's tidy, she's XML. πŸ’…
  • -b base β€” Sets the base URL for resolving relative URLs. By default, the file given as the argument is the base URL. so if you don't say anything, she just assumes your input file knows where it lives. 🏠
  • -f β€” Removes the comments after including the files. which means… hxincl cannot be run on the resulting file later to update the inclusions. 😭 gone. no takebacks. (Mnemonic: final or frozen.) this is the "we're committing, no editing later" option, fr fr.
  • -s name=substitution β€” Include a different file than the one mentioned in the directive. so if the comment is
<!-- include "name" -->

then the file substitution gets included instead. and if the file name in the comment includes a variable called name delimited by %, e.g.

<!-- include "xxx-%name%" -->

then %name% is replaced by substitution, and thus the file xxx-substitution is included. 🧚

The option -s may occur multiple times. %-delimited variables are expanded recursively, i.e., if the substitution text contains a variable, that variable is expanded too. E.g., if the two options -s name=%p1%.rrr and -s p1=subst are given, then the "xxx-%name%" will expand to "xxx-subst.rrr". the layers?? she's peeling them. πŸ§…βœ¨

  • -M target β€” Instead of outputting the input file with all inclusions expanded, output just the list of all files that the input includes, recursively, in the form of a rule that's suitable for a Makefile. The target is printed as the target of that rule. πŸ“‹
  • -G β€” Suppress error messages if a file to include cannot be found. (Only with -M.) like, if it's missing, she just… doesn't say anything about it. πŸ™ˆ

πŸŽ€ OPERANDS πŸŽ€

just the one, bestie:

  • file-or-URL β€” The name of an HTML or XML file, or the URL of one. If it's absent, standard input is read instead. 🌈

⭐ EXIT STATUS ⭐

the receipts, as promised:

  • 0 β€” Successful completion. she ate and left no crumbs. πŸ‘‘
  • > 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/"


πŸ’€ BUGS πŸ’€

okay bestie, listen, she's not perfect and we're being honest about it:

  • Assumes UTF-8 as input. Doesn't expand character entities. Instead, pipe the input through hxunent(1) and asc2xml(1) to convert it to UTF-8. 🫢
  • 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.) πŸ“

🌈 SEE ALSO 🌈

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

the whole friend group, basically. go say hi. πŸ’œ


and that's the tea, bestie β€” this is version 7.x, dated 10 Jul 2011. she's been iconic since 2011 and she's not slowing down. mwah. πŸ’…βœ¨