~adnano/gmnitohtml

58cd619add99a9c516f1224188c2105440f46ffc — Adnan Maolood 1 year, 3 months ago 1f37d4d
Use aria-label for inaccessible <pre> text

Treat preformatted text with non-empty alt text as inaccessible and
provide the alt text in the aria-label attribute.
1 files changed, 7 insertions(+), 1 deletions(-)

M main.go
M main.go => main.go +7 -1
@@ 89,7 89,13 @@ func (h *HTMLWriter) Handle(line gemini.Line) {
	case gemini.LinePreformattingToggle:
		h.pre = !h.pre
		if h.pre {
			fmt.Fprint(h.out, "<pre>\n")
			alt := strings.TrimSpace(string(line))
			if alt != "" {
				alt = html.EscapeString(alt)
				fmt.Fprintf(h.out, "<pre aria-label='%s'>\n", alt)
			} else {
				fmt.Fprint(h.out, "<pre>\n")
			}
		} else {
			fmt.Fprint(h.out, "</pre>\n")
		}