about summary refs log tree commit homepage
path: root/t/hl_mod.t
DateCommit message (Collapse)
2021-10-04hl_mod: don't memoize highlight::codeGenerator objects
Making them immortal doesn't seem worth it, since doing immortal allocations after process startup leads to fragmentation. While the allocations made by highlight are small, those small allocations can break up contiguous regions and prevent consolidation by the malloc implementation. Since instantiating code generators doesn't seem too expensive, just use and delete them ASAP.
2021-09-13tests: add require_cmd, require curl when needed
t/v2mirror.t and t/lei-mirror.t are now skipped when curl is missing (instead of failing in appropriate places). A bunch of which() checks are updated to use require_cmd to avoid explicitly loading Spawn.
2021-06-22t/hl_mod: accept "make" or "makefile" for Makefile
Version 4.0 of highlight has renamed the "make" language to "makefile". So just check the string starts with "make", to handle both 3.x and 4.x. I tested that public-inbox does actually work with highlight 4 -- it can highlight my Makefile fine. :)
2021-01-01update copyrights for 2021
Using "make update-copyrights" after setting GNULIB_PATH in my config.mak
2020-04-20testcommon: spawn-aware system() and qx[] workalikes
Barely noticeable on Linux, but this gives a 1-2% speedup on a FreeBSD 11.3 VM and lets us use built-in redirects rather than relying on /bin/sh.
2020-02-06treewide: run update-copyrights from gnulib for 2019
I didn't wait until September to do it, this year!
2020-01-28t/hl_mod: document IO::Handle for autoflush
We don't need IO::File for this test, but IO::Handle is needed for ->autoflush with Perl <5.14. Note: I haven't tested highlight.pm under 5.10.1 since it's a weird dependency which isn't easy to install w/o distro support.
2019-11-08t/hl_mod.t: remove IPC::Run (and File::Temp) dependency
We already load PublicInbox::Spawn for which(), so using spawn() isn't unreasonable. And rely on "skip" to log the omitted test if w3m is missing, which means we need to update the "&&" escaping test to be self-referential on the same line. File::Temp was totally unused, there; and we can use "open ...,undef" in Perl to easily create anonymous temporary files for use with spawn().
2019-10-31hval: replace "&apos;" with "&#39;" for compatibility
While testing 216light.css changes, I managed to hit some cases where dillo failed to render &apos; correctly, but I also can't reproduce it reliably. Anyways, it's definitely a problem with some old browsers and newer versions of highlight already work around it, but Debian 10.x has 3.41, so use "&#39;" to maximize compatibility.
2019-04-19t/hl_mod: workaround w3m not handling &apos;
This fixes a test failure on my Debian buster system. Bug report filed for w3m to handle "&apos;": https://bugs.debian.org/927409 and for "highlight" to favor "&#39;" in case other browsers fail: https://bugs.debian.org/927410
2019-02-05hlmod: support "```$LANG" blocks in text
This is compatible with Markdown; but we still keep the WYSIWYG nature of plain-text with this. This is only intended for use with our documentation. Enabling any type of Markdown support for emails can lead to incompatibilities or interopability problems with alternative implementations.
2019-02-05hlmod: make into a singleton
It turns out there's no point in having multiple instances of this or having to worry about destruction or destruction ordering. This will make it easier to reuse the one instance we have across different modules.
2019-02-05hlmod: hoist out do_hl_lang sub
We'll want to use to support highlighting syntax used by Markdown and possibly other markup languages (while retaining the raw plain-text layout and formatting).
2019-02-05viewvcs: cleanup utf8 handling
Favor in-place utf8::decode since it's a bit faster without method dispatch overhead; and don't care about validity just yet. HlMod->do_hl itself should return "utf8" strings, since other parts of our code can use it, so it's not the job of ViewVCS to post-process HlMod output.
2019-01-27hlmod: disable enclosing <pre> tag
We already have a <pre> tag in ViewVCS, and nesting <pre> inside the pre-existing <pre> overrides the "white-space:pre" we use to align line numbers.
2019-01-27t/hl_mod: extra check to ensure we escape HTML
Otherwise, it's open season on our users :<
2019-01-21highlight: initial wrapper and PSGI service
I'll probably expose the PSGI service for cgit; but it could be useful to others as well.