~adnano/kiln-devel

Add preformatted alt text v1 REJECTED

alex wennerberg: 1
 Add preformatted alt text

 1 files changed, 7 insertions(+), 1 deletions(-)
I added the function (Text).HTML to the gmi package so that other
projects can use it.


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.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~adnano/kiln-devel/patches/14305/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] Add preformatted alt text Export this patch

---
 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
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: