programmed

hyphenating web pages

For some time, I have been ac­tively seek­ing to im­prove this web site's read­abil­ity and vi­sual ap­peal. Even­tu­ally, I wanted to have jus­ti­fied text. I tried it, and after some time, re­al­ized that it was hard to read. The is­sue was in­con­sis­tency in spac­ing; there would be oc­ca­sional gaps be­tween words. Ideally, a mix of paragraph-at-once text jus­ti­fi­ca­tion and hy­phen­ation may re­solve this is­sue. Not only do HTML and CSS alone not af­ford bet­ter than line-by-line text jus­ti­fi­ca­tion, they do not af­ford client-side text hy­phen­ation. In­stead, the pop­u­lar so­lu­tions ap­pear to be par­tic­u­larly browser-specific, and often in­volve JavaScript. I read on this is­sue, notic­ing that man­ual text hy­phen­ation is achie­ve­able us­ing a spe­cial char­ac­ter code “­”.

The is­sue felt ap­proach­able from a pro­gram­matic stand­point. A stan­dalone pro­gram to hy­phen­ate HTML was easy to imag­ine. And so, I pro­grammed. What re­sulted was au­to­matic hy­phen­ation of HTML, with­out JavaScript or browser-specific in­can­ta­tions ne­ces­si­tated. By means of a sin­gu­lar non-standard de­pen­dency, lib­hy­phen, the hy­phen­ation is syl­labic. The pro­gram I pro­duced is roughly 250 lines of C code, and some­what con­fig­urable by means of an in­cluded header file. This very text is hy­phen­ated us­ing this pro­gram. In the com­pressed tar­ball linked be­low, full Win­dows bi­na­ries are in­cluded.

hyp-1.0.tar.gz, 172 KB

updating this neocities subdomain

A few months into main­tain­ing a neoc­i­ties sub­do­main, I had some gripes. Ad­ding repet­i­tive HTML tags and us­ing the web browser in­ter­face for upload­ing files were rub­bing me the wrong way, and I wanted a page that listed ev­ery file avail­able on the sub­do­main. With a lot of learn­ing along the way, I wrote tools that al­lowed main­tain­ing the sub­do­main to be much more fo­cused on ac­tu­ally valu­able con­tent than on HTML has­sle.

The code for gen­er­at­ing HTML is writ­ten in C89, and the code for di­rect in­ter­ac­tion with the neoc­i­ties API is writ­ten in POSIX Bourne Shell script. The code com­piles and runs on mod­ern OpenBSD (OpenBSD's own ksh, OpenBSD's own make or GNU make, and ei­ther LLVM's clang or Fabrice Bel­lard's tcc), Win­dows (busy­box ash, MinGW make, and ei­ther MinGW gcc or Fabrice Bel­lard's tcc), and Linux (GNU bash or busy­box ash, GNU make, and ei­ther GNU's gcc or LLVM's clang or Fabrice Bel­lard's tcc). An out­dated copy of this site's 'files.json' is pro­vided, so as to pro­vide with the source code some valid in­put.

A few ex­tra tools for generic upload­ing – the most use­ful of which is also writ­ten in C89 and may be used to re­cur­sively upload files and di­rec­to­ries – are in­cluded in the var­i­ous di­rec­tory.

neocities-1.0.tar.gz, 58 KB

solving Advent of Code 2022

As of 2023 Fe­bru­ary 17, I be­gan to com­plete Ad­vent of Code 2022, after hav­ing watched some of Russ Cox's videos fea­tur­ing cre­ative so­lu­tions to Ad­vent of Code 2021. Twenty-six of the fifty stars have been earned, us­ing source code pro­vided here. The so­lu­tions are writ­ten mostly in C89, with there be­ing some AWK, POSIX Bourne Shell script, and in the case of day five, a hacky and ex­pan­sive shell script lever­ag­ing what I now know are some of the GNU ex­ten­sions sup­ported by busy­box ash. I am very glad to have com­pleted as much as I have, and in par­tic­i­pat­ing, I have be­gun to peel away at what I know I don't know.

aoc.tgz, 1088 KB