diff --git a/bin/genhtml b/bin/genhtml
index dc42e55..492cba0 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 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 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
@@ -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..0990f9b 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 appearance 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.