mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
Use a custom Lynx style sheet (LSS file) to work around Lynx bug
Lynx uses a very naïve method of applying styles to HTML elements by hashing the element type and the class name to generate a map of hash:style. After the hash is calculated, Lynx does not go back and check whether or not the actual string values match the LSS properties. See the following links on the Links mailing list: * http://lists.gnu.org/archive/html/lynx-dev/2015-12/msg00037.html * http://lists.gnu.org/archive/html/lynx-dev/2015-12/msg00039.html This patch copies the default Lynx stylesheet but removes highlighting and other styles that would result in unreadable text (due to not enough contrast with the background color), and if the `help` builtin detects that the best web browser to use is Lynx, it instructs it to use this modified stylesheet.
This commit is contained in:
parent
2b425ad221
commit
8b858f2fcc
2 changed files with 110 additions and 0 deletions
104
doc_src/lynx.lss
Normal file
104
doc_src/lynx.lss
Normal file
|
@ -0,0 +1,104 @@
|
|||
# Lynx Style Sheet
|
||||
# Used as a custom style sheet (LSS) for the Lynx browser to work around some
|
||||
# poor defaults. Usage: `lynx -lss=style.lss`
|
||||
#
|
||||
# The next line (beginning with "em") means: use bold if mono, otherwise
|
||||
# brightblue on <defaultbackground> (implicit)
|
||||
em:bold:brightblue
|
||||
strong:bold:brightred
|
||||
b:bold:red
|
||||
i:bold:brightblue
|
||||
a:bold:green
|
||||
img:dim:brown
|
||||
fig:normal:gray
|
||||
caption:reverse:brown
|
||||
hr:normal:yellow
|
||||
blockquote:normal:brightblue
|
||||
ul:normal:brown
|
||||
address:normal:magenta
|
||||
title:normal:magenta
|
||||
tt:dim:brightmagenta:default
|
||||
h1:bold:yellow
|
||||
h2:normal:brown
|
||||
h3:normal:green
|
||||
h4:normal:cyan
|
||||
label:normal:magenta
|
||||
q:normal:yellow
|
||||
small:dim:default
|
||||
big:bold:yellow
|
||||
sup:bold:yellow
|
||||
sub:dim:gray
|
||||
lh:bold:yellow
|
||||
li:normal:magenta
|
||||
code:normal:cyan
|
||||
cite:normal:cyan
|
||||
|
||||
table:normal:brightcyan
|
||||
tr:bold:brown
|
||||
td:normal:default
|
||||
br:normal:default
|
||||
|
||||
# Special styles - not corresponding directly to HTML tags
|
||||
# alert - status bar, when message begins "Alert".
|
||||
# alink - active link
|
||||
# normal - default attributes
|
||||
# status - status bar
|
||||
# whereis - whereis search target
|
||||
#
|
||||
#normal:normal:default:blue
|
||||
alink:reverse:yellow
|
||||
status:reverse:yellow
|
||||
alert:bold:yellow:red
|
||||
whereis:reverse+underline:magenta
|
||||
# currently not used
|
||||
#value:normal:green
|
||||
#high:bold:brightmagenta
|
||||
forwbackw.arrow:reverse
|
||||
|
||||
# Styles with classes - <ul class=red> etc.
|
||||
ul.red:underline:brightred
|
||||
ul.blue:bold:brightblue
|
||||
li.red:reverse:red
|
||||
li.blue:bold:blue
|
||||
strong.a:bold:black
|
||||
/* em.a:reverse:black */
|
||||
em.a:bold:bold
|
||||
strong.b:bold:white
|
||||
em.b:reverse:white
|
||||
strong.debug:reverse:green
|
||||
font.letter:normal:default
|
||||
input.submit:normal:cyan
|
||||
tr.baone:bold:yellow
|
||||
tr.batwo:bold:green
|
||||
tr.bathree:bold:red
|
||||
#
|
||||
# Special handling for link.
|
||||
link:normal:white
|
||||
link.green:bold:brightgreen
|
||||
link.red:bold:black
|
||||
link.blue:bold:white
|
||||
link.toc:bold:black:white
|
||||
# Special cases for link - the rel or title is appended after the class.
|
||||
# <link rel=next class=red href="1">
|
||||
link.red.next:bold:red
|
||||
link.red.prev:bold:yellow
|
||||
link.blue.prev:bold:yellow
|
||||
link.blue.next:bold:blue
|
||||
link.green.toc:bold:white
|
||||
#
|
||||
# Define styles that will be used when syntax highlighting is requested
|
||||
# (commandline option -prettysrc).
|
||||
span.htmlsrc_comment:normal:white
|
||||
span.htmlsrc_tag:normal:white
|
||||
#If you don't like that the tag name and attribute name are displayed
|
||||
#in different colors, comment the following line.
|
||||
span.htmlsrc_attrib:normal:cyan
|
||||
span.htmlsrc_attrval:normal:magenta
|
||||
span.htmlsrc_abracket:normal:white
|
||||
span.htmlsrc_entity:normal:white
|
||||
##span.htmlsrc_href:
|
||||
##span.htmlsrc_entire:
|
||||
span.htmlsrc_badseq:normal:red
|
||||
span.htmlsrc_badtag:normal:red
|
||||
span.htmlsrc_badattr:normal:red
|
||||
span.htmlsrc_sgmlspecial:normal:yellow
|
|
@ -148,6 +148,12 @@ function help --description 'Show help for the fish shell'
|
|||
end
|
||||
eval "$fish_browser $page_url &"
|
||||
else
|
||||
# Work around lynx bug where <div class="contents"> always has the same formatting as links (unreadable)
|
||||
# by using a custom style sheet. See https://github.com/fish-shell/fish-shell/issues/4170
|
||||
set -l local_file 0
|
||||
if eval $fish_browser --version 2>/dev/null | string match -qr Lynx
|
||||
set fish_browser $fish_browser -lss={$__fish_help_dir}/fish.lss
|
||||
end
|
||||
eval $fish_browser $page_url
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue