fix(man): use italics for <bs>_ (#22086)

fix(man): use italics for <bs>_

Even though underline is strictly what this should be. <bs>_ was used by
nroff to indicate italics which wasn't possible on old typewriters so
underline was used. Modern terminals now support italics so lets use
that now.

See:
- https://unix.stackexchange.com/questions/274658/purpose-of-ascii-text-with-overstriking-file-format/274795#274795
- https://cmd.inp.nsk.su/old/cmd2/manuals/unix/UNIX_Unleashed/ch08.htm
This commit is contained in:
Lewis Russell 2023-02-01 17:21:42 +00:00 committed by GitHub
parent 4cc0d6b854
commit 9ce44a750c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -149,15 +149,21 @@ local function highlight_line(line, linenr)
if overstrike then
local last_hl = hls[#hls]
if char == prev_char then
if char == '_' and attr == UNDERLINE and last_hl and last_hl.final == byte then
-- This underscore is in the middle of an underlined word
attr = UNDERLINE
if char == '_' and attr == ITALIC and last_hl and last_hl.final == byte then
-- This underscore is in the middle of an italic word
attr = ITALIC
else
attr = BOLD
end
elseif prev_char == '_' then
-- char is underlined
attr = UNDERLINE
-- Even though underline is strictly what this should be. <bs>_ was used by nroff to
-- indicate italics which wasn't possible on old typewriters so underline was used. Modern
-- terminals now support italics so lets use that now.
-- See:
-- - https://unix.stackexchange.com/questions/274658/purpose-of-ascii-text-with-overstriking-file-format/274795#274795
-- - https://cmd.inp.nsk.su/old/cmd2/manuals/unix/UNIX_Unleashed/ch08.htm
-- attr = UNDERLINE
attr = ITALIC
elseif prev_char == '+' and char == 'o' then
-- bullet (overstrike text '+^Ho')
attr = BOLD

View File

@ -59,7 +59,7 @@ describe(':Man', function()
screen:expect([[
^this {b:is} {b:a} test |
with {u:overstruck} text |
with {i:overstruck} text |
{eob:~ }|
{eob:~ }|
|
@ -98,7 +98,7 @@ describe(':Man', function()
screen:expect([[
^this {b:is} {b:} test |
with {u:överstrũck} te{i:xt} |
with {i:överstrũck} te{i:xt} |
{eob:~ }|
{eob:~ }|
|
@ -115,7 +115,7 @@ describe(':Man', function()
screen:expect([[
{b:^_begins} |
{b:mid_dle} |
{u:mid_dle} |
{i:mid_dle} |
{eob:~ }|
|
]])