From 339a3191c8ced69f3339297a88d8b4503c78d86e Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Tue, 12 Jan 2021 23:12:22 -0500 Subject: Avoid matching tag text inside HTML elements --- bin/htagml.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/htagml.c b/bin/htagml.c index 0e14df77..f94e7bfc 100644 --- a/bin/htagml.c +++ b/bin/htagml.c @@ -61,6 +61,17 @@ static size_t escape(bool esc, const char *ptr, size_t len) { return len; } +static char *hstrstr(char *haystack, char *needle) { + while (haystack) { + char *elem = strchr(haystack, '<'); + char *match = strstr(haystack, needle); + if (!match) return NULL; + if (!elem || match < elem) return match; + haystack = strchr(elem, '>'); + } + return NULL; +} + int main(int argc, char *argv[]) { bool pre = false; bool pipe = false; @@ -157,10 +168,10 @@ int main(int argc, char *argv[]) { } char *text = tag->tag; - char *match = strstr(buf, text); + char *match = (pipe ? hstrstr(buf, text) : strstr(buf, text)); if (!match && tag->tag[0] == 'M') { text = "main"; - match = strstr(buf, text); + match = (pipe ? hstrstr(buf, text) : strstr(buf, text)); } if (match) escape(!pipe, buf, match - buf); printf(" diff
path: root/doc/zlib/crc32.3 (unfollow)
Commit message (Expand)Author
2022-05-16Add all possible hostnames to ssh configJune McEnroe
2022-05-16Add back grc aliasJune McEnroe
2022-05-10Update "Care" with certificate timelineJune McEnroe
2022-05-08Add CirceJune McEnroe
2022-04-20Revert "Make (pun) the dependencies make (pun) more sense"June McEnroe
2022-04-20Set txt mtimes to source mtimesJune McEnroe
2022-04-20Make (pun) the dependencies make (pun) more senseJune McEnroe
2022-04-17Add HenchJune McEnroe
2022-04-14Publish "Agency"June McEnroe
2022-04-13Swap dates so the difference is always positiveJune McEnroe
2022-04-04Update "Care"June McEnroe
2022-04-03Publish "Care"June McEnroe
2022-03-31Publish "Compassion"June McEnroe
2022-03-24Skip matches with ident chars on either sideJune McEnroe
2022-03-24Add The Invisible Life of Addie LaRueJune McEnroe
2022-03-22Source ~/.profile.local if it existsJune McEnroe
2022-03-18Publish "Addendum 2021"June McEnroe
2022-03-16Remove wcwidth portJune McEnroe
2022-03-16Remove -j4 from ./PlanJune McEnroe
2022-03-15Rewrite Linux install.sh for DebianJune McEnroe
2022-03-15Remove dashJune McEnroeal PeopleJune McEnroe
Unbearably straight. Eyerolls and sighs per page off the charts. Shout out to Joanna, I guess. I kinda like the lack of quotation marks though to be honest. After half of the Ruth Ozeki novel and now this, I need to get back to some genre fiction.
2022-07-26Rewrite glitch from new pngoJune McEnroe
2022-07-26Update Care with time-to-ID and piercingsJune McEnroe
2022-07-26Add -w to upJune McEnroe
2022-07-13Set push.autoSetupRemoteJune McEnroe
2022-07-08Remove TOURJune McEnroe
There is not that much distinct stuff here anymore.
2022-07-03Add The Bone Shard EmperorJune McEnroe
Suffers a little bit from middle book but I really enjoyed it. Read it faster than the first one too, despite its length.
2022-06-25Bump xterm font size to 12June McEnroe
2022-06-10Handle subshells (and functions) inside substitutionsJune McEnroe
2022-06-10Switch to jorts Install scriptJune McEnroe
2022-06-08Indicate if still reading or no resultsJune McEnroe
2022-06-08Add Maiden, Mother, CroneJune McEnroe
Mixed bag like most collections of short stories. Some of them are pretty good. The author of the worst written story also has the worst written bio.
2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe
2022-06-03Set line number on File linesJune McEnroe
2022-06-03Stop polling stdin after EOFJune McEnroe
2022-06-02Set TABSIZE=4June McEnroe
Absolutely indiscriminately.
2022-06-02Do basic match highlightingJune McEnroe
2022-06-02Clean up parsing a littleJune McEnroe
2022-06-02Don't duplicate path stringJune McEnroe
2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe
For some reason I haven't been able to figure out, trying to poll /dev/tty returns POLLNVAL (and this was using 100% CPU looping), but using stderr instead works fine.
2022-06-02Add initial working version of qfJune McEnroe
2022-05-29Set prompt for okshJune McEnroe