~adnano/kiln-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
8 2

[PATCH] Add preformatted alt text

Details
Message ID
<20201014183414.27099-1-alex@alexwennerberg.com>
DKIM signature
fail
Download raw message
Patch: +7 -1 DKIM signature: fail
---
 html.go | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/html.go b/html.go
index cb51851..1620a84 100644
--- a/html.go
+++ b/html.go
@@ -34,8 +34,14 @@ func gmiToHTML(text gmi.Text) []byte {
			fmt.Fprintf(&b, "<p><a href='%s'>%s</a></p>\n", url, name)
		case gmi.LinePreformattingToggle:
			pre = !pre
			altText := string(l.(gmi.LinePreformattingToggle))
			if pre {
				fmt.Fprint(&b, "<pre>\n")
				if altText != "" {
					altText = html.EscapeString(altText)
					fmt.Fprintf(&b, "<pre alt='%s'>\n", altText)
				} else {
					fmt.Fprint(&b, "<pre>\n")
				}
			} else {
				fmt.Fprint(&b, "</pre>\n")
			}
-- 
2.20.1
Details
Message ID
<C6CTXD4PZ5RH.358JIHV098SFK@debian-thinkpad>
In-Reply-To
<20201014183414.27099-1-alex@alexwennerberg.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Still new to git send email -- wanted to add some comments.

Thanks for putting this together! I have put together some similar code,
but it is much messier than yours:
https://git.sr.ht/~alexwennerberg/gemtext2html and
https://git.sr.ht/~alexwennerberg/flounder/tree/master/https/src/utils/gemtext2html.rs

This patch adds alt text to preformatted lines

Have you thought about splitting out this into a separate library so
other projects can use it?

Alex

On Wed Oct 14, 2020 at 11:34 AM PDT, alex wennerberg wrote:
> ---
> html.go | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/html.go b/html.go
> index cb51851..1620a84 100644
> --- a/html.go
> +++ b/html.go
> @@ -34,8 +34,14 @@ func gmiToHTML(text gmi.Text) []byte {
> fmt.Fprintf(&b, "<p><a href='%s'>%s</a></p>\n", url, name)
> case gmi.LinePreformattingToggle:
> pre = !pre
> + altText := string(l.(gmi.LinePreformattingToggle))
> if pre {
> - fmt.Fprint(&b, "<pre>\n")
> + if altText != "" {
> + altText = html.EscapeString(altText)
> + fmt.Fprintf(&b, "<pre alt='%s'>\n", altText)
> + } else {
> + fmt.Fprint(&b, "<pre>\n")
> + }
> } else {
> fmt.Fprint(&b, "</pre>\n")
> }
> --
> 2.20.1
Details
Message ID
<C6D551SJ31YN.2L8L951UJBPWO@nitro>
In-Reply-To
<C6CTXD4PZ5RH.358JIHV098SFK@debian-thinkpad> (view parent)
DKIM signature
missing
Download raw message
On Wed Oct 14, 2020 at 7:35 AM EDT, alex wennerberg wrote:
> This patch adds alt text to preformatted lines
I don't think that the 'alt' attribute is valid for <pre> elements.

> Have you thought about splitting out this into a separate library so
> other projects can use it?
I have, but I'm not sure that it belongs in the gmi library. I'll
reconsider it.
Details
Message ID
<C6D57RW4MGZC.3BDZEOX1CFVJ5@debian-thinkpad>
In-Reply-To
<C6D551SJ31YN.2L8L951UJBPWO@nitro> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Wed Oct 14, 2020 at 8:22 PM PDT, Adnan Maolood wrote:
> On Wed Oct 14, 2020 at 7:35 AM EDT, alex wennerberg wrote:
> > This patch adds alt text to preformatted lines
> I don't think that the 'alt' attribute is valid for <pre> elements.

You're right -- do you think "title" would be more appropriate?
Details
Message ID
<C6D5RG3C90YZ.B0ZDHJQAP2FA@nitro>
In-Reply-To
<C6D57RW4MGZC.3BDZEOX1CFVJ5@debian-thinkpad> (view parent)
DKIM signature
missing
Download raw message
On Wed Oct 14, 2020 at 4:26 PM EDT, alex wennerberg wrote:
> You're right -- do you think "title" would be more appropriate?

I'm not sure. 'title' would cause the alt text to show when hovering
over the preformatted text. I don't think that is desirable behavior.

Another thing to note is that alt text may be used to specify a
programming language that the preformatted text is written in. It's
unclear how a client should differentiate between alt text for ASCII art
and alt text for code.

This needs some more thought.
Details
Message ID
<C6D6MM3GVY04.37T1C60EE82K8@debian-thinkpad>
In-Reply-To
<C6D5RG3C90YZ.B0ZDHJQAP2FA@nitro> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Wed Oct 14, 2020 at 8:52 PM PDT, Adnan Maolood wrote:
> On Wed Oct 14, 2020 at 4:26 PM EDT, alex wennerberg wrote:
> > You're right -- do you think "title" would be more appropriate?
>
> I'm not sure. 'title' would cause the alt text to show when hovering
> over the preformatted text. I don't think that is desirable behavior.
>
> Another thing to note is that alt text may be used to specify a
> programming language that the preformatted text is written in. It's
> unclear how a client should differentiate between alt text for ASCII art
> and alt text for code.
>
> This needs some more thought.

Good point, I had only thought about the alt tag in terms of
accessibility. I don't think we'd be able to meaningfully parse something like the
programming language without a js syntax highlighting library

Alex
Details
Message ID
<C6D71KSSEIQI.1EZ23WPO6ZJ0H@nitro>
In-Reply-To
<C6D6MM3GVY04.37T1C60EE82K8@debian-thinkpad> (view parent)
DKIM signature
missing
Download raw message
I added the function (Text).HTML to the gmi package so that other
projects can use it.
Details
Message ID
<C6D74PTXJ2LS.277JAMZ4A3RQL@debian-thinkpad>
In-Reply-To
<C6D71KSSEIQI.1EZ23WPO6ZJ0H@nitro> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
On Wed Oct 14, 2020 at 9:52 PM PDT, Adnan Maolood wrote:
> I added the function (Text).HTML to the gmi package so that other
> projects can use it.

Awesome! I'm (slowly) working on a rewrite of flounder.online in Go that
will probably use it
Details
Message ID
<C6IRDMDDL9JB.HZAPARXXT9JV@nitro>
In-Reply-To
<C6D74PTXJ2LS.277JAMZ4A3RQL@debian-thinkpad> (view parent)
DKIM signature
missing
Download raw message
Perhaps we could use <figure> and <figcaption>.

	<figure>
		<pre>preformatted text</pre>
  		<figcaption>alt text</figcaption>
	</figure>

Or maybe the aria-label attribute:

	<pre aria-label="alt-text">preformatted text</pre>

Now if only there was a way to distinguish between code and ASCII art.
Review patch Export thread (mbox)