From c26b1fedc4d03fda7b061a32ad021d001ea5f2ff Mon Sep 17 00:00:00 2001 From: Benedikt Roland Date: Thu, 12 Feb 2026 08:33:00 +0100 Subject: [PATCH 1/2] Expanded tab settings to accommodate different styles. '--num-spaces' now allows any numerical value. alter apperance via negative values. replace with spaces via positive values (backwards compatible). do not alter tabs or their apperance via 0. help and man pages updated to reflect the changes. default (8) is unchanged. minor tweak to man pages: num replaced with spaces for consistency. NOTE: uses CSS3 'tab-size' (for altering tab apperance). Widely available since 2021. Webkit since around 2013. --- bin/genhtml | 27 +++++++++++++++++---------- man/genhtml.1 | 13 +++++++++++-- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/bin/genhtml b/bin/genhtml index dc42e55..24cc5ec 100755 --- a/bin/genhtml +++ b/bin/genhtml @@ -7254,12 +7254,6 @@ if ($css_filename) { } } -# Make sure tab_size is within valid range -if ($tab_size < 1) { - print(STDERR "ERROR: invalid number of spaces specified: $tab_size!\n"); - exit(1); -} - # Get HTML prolog and epilog $html_prolog = get_html_prolog($html_prolog_file); $html_epilog = get_html_epilog($html_epilog_file); @@ -7474,7 +7468,10 @@ HTML OUTPUT --header-title BANNER Banner at top of each HTML page --footer FOOTER Footer at bottom of each HTML page --no-sourceview Do not create source code view - --num-spaces NUM Replace tabs with NUM spaces in source view + --num-spaces NUM change apperance of tabs in source view + NUM == 0 will not touch tabs + NUM > 0 will replace them with NUM spaces + NUM < 0 will only change their apperance --legend Include color legend in HTML output --html-prolog FILE Use FILE as HTML prolog for generated pages --html-epilog FILE Use FILE as HTML epilog for generated pages @@ -8477,9 +8474,11 @@ sub escape_html($) $string =~ s/>/>/g; # > -> > $string =~ s/\"/"/g; # " -> " - while ($string =~ /^([^\t]*)(\t)/) { - my $replacement = " " x ($tab_size - (length($1) % $tab_size)); - $string =~ s/^([^\t]*)(\t)/$1$replacement/; + if ($tab_size > 0) { + while ($string =~ /^([^\t]*)(\t)/) { + my $replacement = " " x ($tab_size - (length($1) % $tab_size)); + $string =~ s/^([^\t]*)(\t)/$1$replacement/; + } } $string =~ s/\n/
/g; # \n ->
@@ -9358,6 +9357,7 @@ sub write_css_file() font-family: monospace; white-space: pre; margin-top: 2px; + tab-size: #TAB_SIZE; } /* elided/removed code */ @@ -9559,6 +9559,13 @@ END_OF_DATE_SPAN $css_data =~ s/$key/$color/gm; } + if ($tab_size < 0) { + my $abs_tab_size = abs($tab_size); + $css_data =~ s/#TAB_SIZE/$abs_tab_size/gm; + } else { + $css_data =~ s/^.*#TAB_SIZE.*\n//gm; + } + print(CSS_HANDLE $css_data); close(CSS_HANDLE) or die("unable to close CSS handle: $!\n"); diff --git a/man/genhtml.1 b/man/genhtml.1 index fa6292e..09ee2fa 100644 --- a/man/genhtml.1 +++ b/man/genhtml.1 @@ -2686,8 +2686,17 @@ the coverage criteria check or the serialized coverage DB, .RE .BI "\-\-num\-spaces " spaces .RS -Replace tabs in source view with -.I num +Change apperance of tabs in source view according to +.IR spaces . + +When set to 0, tabs and their behaviour will be the browser's default. +.br +Negative values will set the rendered width in the source view to +.I spaces +spaces. +.br +Positive values will replace tabs with +.I spaces spaces. Default value is 8. From a5170c1d6a51809ec11ab0344c65cfbe1802c738 Mon Sep 17 00:00:00 2001 From: Benedikt Roland Date: Thu, 12 Feb 2026 15:56:15 +0100 Subject: [PATCH 2/2] fix typo --- bin/genhtml | 4 ++-- man/genhtml.1 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/genhtml b/bin/genhtml index 24cc5ec..492cba0 100755 --- a/bin/genhtml +++ b/bin/genhtml @@ -7468,10 +7468,10 @@ HTML OUTPUT --header-title BANNER Banner at top of each HTML page --footer FOOTER Footer at bottom of each HTML page --no-sourceview Do not create source code view - --num-spaces NUM change apperance of tabs in source view + --num-spaces NUM change appearance of tabs in source view NUM == 0 will not touch tabs NUM > 0 will replace them with NUM spaces - NUM < 0 will only change their apperance + NUM < 0 will only change their appearance --legend Include color legend in HTML output --html-prolog FILE Use FILE as HTML prolog for generated pages --html-epilog FILE Use FILE as HTML epilog for generated pages diff --git a/man/genhtml.1 b/man/genhtml.1 index 09ee2fa..0990f9b 100644 --- a/man/genhtml.1 +++ b/man/genhtml.1 @@ -2686,7 +2686,7 @@ the coverage criteria check or the serialized coverage DB, .RE .BI "\-\-num\-spaces " spaces .RS -Change apperance of tabs in source view according to +Change appearance of tabs in source view according to .IR spaces . When set to 0, tabs and their behaviour will be the browser's default.