godoc: allow line numbers to be searched by ctrl+f
We used a css-pseudo class rule to move the line number inside the pseudo element. The idea was to prevent line numbers from getting selected while copying the code. But this was already implemented with the "user-select: none" rule. Since the spec was undefined on "user-select", we had to resort to the pseudo-class, but now both FF and Chrome implement the correct behavior. Hence, moving the content to be inside the span, and removing the pseudo-class rule. Manually tested with Chrome 63 and Firefox 58 on Ubuntu. Fixes golang/go#23724 Change-Id: I3e733db766b44875ba6bc3f6985cde2559d116e2 Reviewed-on: https://go-review.googlesource.com/93975 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
This commit is contained in:
parent
a4ae709237
commit
ce871d1788
|
@ -644,7 +644,7 @@ 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
|
// 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
|
// it indents a full 8 spaces, hence the two nbsp's. Otherwise the tab
|
||||||
// character only indents about two spaces.
|
// character only indents about two spaces.
|
||||||
fmt.Fprintf(saved, `<span id="L%d" class="ln" data-content="%6d"> </span>`, n, n)
|
fmt.Fprintf(saved, `<span id="L%d" class="ln">%6d </span>`, n, n)
|
||||||
n++
|
n++
|
||||||
saved.Write(line)
|
saved.Write(line)
|
||||||
saved.WriteByte('\n')
|
saved.WriteByte('\n')
|
||||||
|
|
|
@ -2915,11 +2915,7 @@ pre .ln {
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.ln::before {
|
|
||||||
/* Inserting the line numbers as a ::before pseudo-element avoids making
|
|
||||||
* them selectable; it's the trick Github uses as well. */
|
|
||||||
content: attr(data-content);
|
|
||||||
}
|
|
||||||
body {
|
body {
|
||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,7 @@ pre .ln {
|
||||||
-ms-user-select: none;
|
-ms-user-select: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
.ln::before {
|
|
||||||
/* Inserting the line numbers as a ::before pseudo-element avoids making
|
|
||||||
* them selectable; it's the trick Github uses as well. */
|
|
||||||
content: attr(data-content);
|
|
||||||
}
|
|
||||||
body {
|
body {
|
||||||
color: #222;
|
color: #222;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue