URI: 
       link references improvements and link references with the -s and -u flag - webdump - HTML to plain-text converter for webpages
  HTML git clone git://git.codemadness.org/webdump
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
   DIR commit ffac8c54d4e3ed9e7d5e8cb9c27df7d788089449
   DIR parent b078d0218a1f4dcfeb59fdbff2fe356b4f30ddc3
  HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Thu,  2 Jul 2026 19:40:02 +0200
       
       link references improvements and link references with the -s and -u flag
       
       - When specifying -x it does not show link references on the bottom (requires -l flag).
       - When using the -u flag all link references as added, but as hidden links.
       - When using the -s flag all link references as added, but as visible links (if
         it was originally visible).
       
       This makes it more logical to use with the -x flag.
       
       Diffstat:
         M webdump.c                           |      80 ++++++++++++++++---------------
       
       1 file changed, 41 insertions(+), 39 deletions(-)
       ---
   DIR diff --git a/webdump.c b/webdump.c
       @@ -1479,7 +1479,7 @@ handleinlinealt(void)
        
                /* do not show the alt text if the element is hidden */
                cur = &nodes[curnode];
       -        if (cur->tag.displaytype & DisplayNone)
       +        if (reader_ignore || (cur->tag.displaytype & DisplayNone))
                        return;
        
                /* show img alt attribute as text. */
       @@ -1626,23 +1626,25 @@ printlinkrefs(void)
                        }
                }
        
       -        printf("\nReferences\n\n");
       +        if (showrefbottom) {
       +                printf("\nReferences\n\n");
        
       -        for (i = 0; i < nvisrefs; i++) {
       -                ref = visrefs[i];
       -                printf(" %zu. ", ref->linknr);
       -                printuri(ref->url);
       -                printf(" (%s)\n", ref->type);
       -        }
       +                for (i = 0; i < nvisrefs; i++) {
       +                        ref = visrefs[i];
       +                        printf(" %zu. ", ref->linknr);
       +                        printuri(ref->url);
       +                        printf(" (%s)\n", ref->type);
       +                }
        
       -        if (nhiddenrefs > 0)
       -                printf("\n\nHidden references\n\n");
       -        /* hidden links don't have a link number, just count them */
       -        for (i = 0; i < nhiddenrefs; i++) {
       -                ref = hiddenrefs[i];
       -                printf(" %zu. ", ref->linknr);
       -                printuri(ref->url);
       -                printf(" (%s)\n", ref->type);
       +                if (nhiddenrefs > 0)
       +                        printf("\n\nHidden references\n\n");
       +                /* hidden links don't have a link number, just count them */
       +                for (i = 0; i < nhiddenrefs; i++) {
       +                        ref = hiddenrefs[i];
       +                        printf(" %zu. ", ref->linknr);
       +                        printuri(ref->url);
       +                        printf(" (%s)\n", ref->type);
       +                }
                }
        }
        
       @@ -1860,29 +1862,31 @@ endnode(struct node *cur)
                ishidden = reader_ignore || (cur->tag.displaytype & DisplayNone);
        
                /* add link and show the link number in the visible order */
       -        if (!ishidden && nodes_links[curnode].len > 0) {
       +        if (nodes_links[curnode].len > 0) {
                        ref = addlinkref(nodes_links[curnode].data,
                                cur->tag.name, cur->tag.id, ishidden);
        
       -                if (showrefinline || showurlinline) {
       -                        hflush();
       -                        startmarkup(MarkupReverse);
       -                }
       +                if (!ishidden) {
       +                        if (showrefinline || showurlinline) {
       +                                hflush();
       +                                startmarkup(MarkupReverse);
       +                        }
        
       -                if (showrefinline)
       -                        hprintf("[%zu]", ref->linknr);
       -                if (showurlinline) {
       -                        hputchar('[');
       -                        if (ref->tagid != TagA) {
       -                                hprint(ref->type);
       -                                hprint(": ");
       +                        if (showrefinline)
       +                                hprintf("[%zu]", ref->linknr);
       +                        if (showurlinline) {
       +                                hputchar('[');
       +                                if (ref->tagid != TagA) {
       +                                        hprint(ref->type);
       +                                        hprint(": ");
       +                                }
       +                                hprinturi(ref->url);
       +                                hputchar(']');
       +                        }
       +                        if (showrefinline || showurlinline) {
       +                                endmarkup(MarkupReverse);
       +                                hflush();
                                }
       -                        hprinturi(ref->url);
       -                        hputchar(']');
       -                }
       -                if (showrefinline || showurlinline) {
       -                        endmarkup(MarkupReverse);
       -                        hflush();
                        }
                }
        
       @@ -2193,11 +2197,9 @@ xmltagstartparsed(XMLParser *p, const char *t, size_t tl, int isshort)
                /* indent for this tag */
                cur->indent = cur->tag.indent;
        
       -        if (!reader_ignore) {
       -                /* add link reference, print links and alt text */
       -                handleinlinelink();
       -                handleinlinealt();
       -        }
       +        /* add link reference, print links and alt text */
       +        handleinlinelink();
       +        handleinlinealt();
        
                /* <select><option> */
                if ((cur->tag.displaytype & DisplayOption) && parent) {