Files
w3m/parsetag.c
Storm Dragon 16d146a9ae Implement reliable HTML heading navigation using tag-based detection
This commit completely overhauls the heading navigation feature (d/shift+D keys)
to use actual HTML tag information instead of unreliable text-based heuristics.

Key improvements:
- Navigation now works 100% reliably by tracking actual <h1>-<h6> HTML tags
- Eliminates false positives from bold text, links, and buttons
- No longer navigates to blank lines around headings
- Provides true screen reader-style heading navigation

Technical implementation:
- Added LINE_FLAG_HEADING flag to mark heading lines during HTML processing
- Enhanced readbuffer with in_heading field to track heading tag state
- Modified HTML parser to set/clear heading flags on <h>/<\/h> tags
- Updated TextLine and Line structures to preserve heading information
- Simplified navigation functions to use reliable flag-based detection
- Added content length check to avoid marking blank spacing lines

Also includes compilation fixes for modern GCC:
- Fixed function pointer type compatibility issues
- Updated signal handler declarations
- Resolved deprecation warnings for various system calls

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-16 02:11:37 -04:00

60 lines
1.1 KiB
C

/* $Id: parsetag.c,v 1.4 2001/11/20 17:49:23 ukai Exp $ */
#define _GNU_SOURCE
#include <strings.h>
#include "myctype.h"
#include "indep.h"
#include "Str.h"
#include "parsetag.h"
char *
tag_get_value(struct parsed_tagarg *t, char *arg)
{
for (; t; t = t->next) {
if (!strcasecmp(t->arg, arg))
return t->value;
}
return NULL;
}
int
tag_exists(struct parsed_tagarg *t, char *arg)
{
for (; t; t = t->next) {
if (!strcasecmp(t->arg, arg))
return 1;
}
return 0;
}
struct parsed_tagarg *
cgistr2tagarg(char *cgistr)
{
Str tag;
Str value;
struct parsed_tagarg *t0, *t;
t = t0 = NULL;
do {
t = New(struct parsed_tagarg);
t->next = t0;
t0 = t;
tag = Strnew();
while (*cgistr && *cgistr != '=' && *cgistr != '&')
Strcat_char(tag, *cgistr++);
t->arg = Str_form_unquote(tag)->ptr;
t->value = NULL;
if (*cgistr == '\0')
return t;
else if (*cgistr == '=') {
cgistr++;
value = Strnew();
while (*cgistr && *cgistr != '&')
Strcat_char(value, *cgistr++);
t->value = Str_form_unquote(value)->ptr;
}
else if (*cgistr == '&')
cgistr++;
} while (*cgistr);
return t;
}