9front - general discussion about 9front
 help / color / mirror / Atom feed
From: mkf9 <mkf9@riseup.net>
To: 9front@9front.org
Subject: [9front] LN macro
Date: Thu, 3 Oct 2024 16:10:18 +0330	[thread overview]
Message-ID: <a0b0ba06-d844-1626-d809-22edc3b50997@riseup.net> (raw)

Hello.
I have a patch for ms2html, which adds a new macro to insert hyperlinks
into documents, currently, the best solution we have currently is 
hard-coding html tags,
example in htmlroff:
.html a <a href="/link">
this is a link
.html a

or in ms2html:
._H <a href="/link">
this is a link
._H </a>

both of which are not very good. It'd be nice if we had a
common way to insert hyper links into html and pdf (and possibly ps) 
documents, without hard-coding any thing specific to those formats.

this is what .LN macro tries to solve, at least for ms2html, for now.
i'll send a patch for htmlroff and mhtml later on.

comments are welcome. :)

diff d8973bdc75d5e7c7a35855f78ade347c01f985f1 uncommitted
--- a/sys/src/cmd/ms2html.c
+++ b/sys/src/cmd/ms2html.c
@@ -87,13 +87,14 @@
  F g_br, g_ft, g_sp, g_de, g_lf, g_so, g_rm, g_in;
  F g_nr, g_ig, g_RT, g_BS, g_BE, g_LB, g_ta;

-/* macros to include ML in output */
-F g__H, g__T;
+/* macros to include HTML in output */
+F g__H, g__T, g_LN;

  Goobie gtab[] =
  {
  	{ "_T", g__T, },
  	{ "_H", g__H, },
+	{ "LN", g_LN, },
  	{ "1C",	g_ignore, },
  	{ "2C",	g_ignore, },
  	{ "AB", g_AB, },
@@ -2264,6 +2265,25 @@
  	printargs(argc, argv);
  	Bprint(&bout, "</title></head><body>\n");
  	titleseen = 1;
+}
+
+/* HTML <a> tag */
+void
+g_LN(int argc, char **argv)
+{
+	static int onlink = 0;
+	if(onlink)
+	{
+		Bprint(&bout, "</a>\n");
+		onlink = 0;
+	}
+	else
+	{
+		Bprint(&bout, "<a href=\"");
+		printargs(argc, argv);
+		Bprint(&bout, "\">\n");
+		onlink = 1;
+	}
  }

  void

             reply	other threads:[~2024-10-03 18:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-03 12:40 mkf9 [this message]
2024-10-03 19:54 ` Jacob Moody
2024-10-04 10:00   ` rgl
2024-10-05 15:17 ` Lennart Jablonka
2024-10-05 22:05   ` Lennart Jablonka

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a0b0ba06-d844-1626-d809-22edc3b50997@riseup.net \
    --to=mkf9@riseup.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).