godoc: fix indenting on Firefox

See comment in the patch for an explanation, Firefox (specifically
with the Menlo font) does not like tabs beginning in column 9, so we
start it in column 10.

Updates webcompat/web-bugs#17530
Fixes golang/go#26316
Fixes golang/go#23500

Change-Id: I4c96118b8c3b13ee1fd21ce85bd7c681e99a4b4f
Reviewed-on: https://go-review.googlesource.com/131716
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
Kevin Burke 2018-08-27 16:02:08 -06:00 committed by Daniel Martí
parent 6cd1fcedba
commit 4bc20fc791
3 changed files with 18 additions and 2 deletions

View File

@ -658,7 +658,15 @@ func formatGoSource(buf *bytes.Buffer, text []byte, links []analysis.Link, patte
//
// The first tab for the code snippet needs to start in column 9, so
// it indents a full 8 spaces, hence the two nbsp's. Otherwise the tab
// character only indents about two spaces.
// character only indents a short amount.
//
// Due to rounding and font width Firefox might not treat 8 rendered
// characters as 8 characters wide, and subsequently may treat the tab
// character in the 9th position as moving the width from (7.5 or so) up
// to 8. See
// https://github.com/webcompat/web-bugs/issues/17530#issuecomment-402675091
// for a fuller explanation. The solution is to add a CSS class to
// explicitly declare the width to be 8 characters.
fmt.Fprintf(saved, `<span id="L%d" class="ln">%6d&nbsp;&nbsp;</span>`, n, n)
n++
saved.Write(line)

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,14 @@ pre .ln {
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
/* Ensure 8 characters in the document - which due to floating
* point rendering issues, might have a width of less than 1 each - are 8
* characters wide, so a tab in the 9th position indents properly. See
* https://github.com/webcompat/web-bugs/issues/17530#issuecomment-402675091
* for more information. */
display: inline-block;
width: 8ch;
}
a,