REUSING-TAGS(7) Miscellaneous Information Manual REUSING-TAGS(7) NAME reusing tags – beyond ctags DESCRIPTION I've tried to start writing this post a couple times now and I keep getting bogged down in explanations, so I'm just going to tell you about some cool things I did and hope they make sense. When I wrote my first syntax highlighter, I decided that function definitions should have anchor links, because line number anchor links are entirely useless if you expect the file to change at all. Since the syntax highlighter was somewhat deliberately just a big pile of regex, I hacked in more regex to try to identify function and type definitions. It wasn't elegant and it didn't always work well. It did work though, and I found the links very useful. Recently I was thinking about the lexer generator lex(1) and decided to rewrite the syntax highlighter using it. Really syntax highlighting is no different than lexical analysis. I ran into a problem though, trying to preserve my anchor link function, because really that should involve some amount of parsing. Trying to port my regex hacks to lex(1) made the lexers way more complicated and less reliable, so I gave up on it for a while. And then, probably in the shower, I realized I was approaching it completely from the wrong direction. There's already a tool that does what I want, and I already use it: ctags(1). All I need to do is use its output to insert anchor links into my syntax highlighter output. In an afternoon I wrote htagml(1), which loads tag definitions for its input file, then scans through the input for where they match. It can either HTML-escape the input as it goes, or use already formatted HTML being piped into it from a syntax highlighter. The result is three simple tools working together to accomplish what a more complex tool couldn't reliably achieve. I'm very pleased with it, and I've updated my site and cgit to use the new lex(1)-based highlighter, ctags(1) and htagml(1). I'm currently missing a lexer for sh(1), but I plan to write it eventually. I also want to write a tool to generate tags for make(1), mdoc(7) and perhaps sh(1). The cool thing about generating more kinds of tags is that they'll not only improve the HTML output, they'll also be usable in my editor. Speaking of generating different kinds of tags, I also wrote some scripts not too long ago for reading IETF RFCs offline. The plain text files are available to rsync(1), but they're hard to navigate on their own. By scanning the files for headings and generating tags, it allows jumping to sections using :ta or ^] in vi(1). For nvim(1) I also added an :RFC command to open an RFC by number and set up ^] to work optimally for them. I'm still using vi(1) for most of my editing, by the way. And of course ctags(1) was made to work with it! Simple old tools are really doing it for me lately. SEE ALSO htagml: https://causal.agency/bin/htagml.html hilex: https://causal.agency/bin/hilex.html rfctags: https://git.causal.agency/src/tree/doc/rfc AUTHORS june ADDENDUM catgirl(1), pounce(1), litterbox(1) and scooper(1) all have new releases, if you're using any of them. Also, this space is now available over gopher, if that's your sort of thing. Causal Agency January 17, 2021 Causal Agency