* mandoc: For .%R RFC, link to rfc-editor.org in -T markdown output just
@ 2025-01-20 7:01 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2025-01-20 7:01 UTC (permalink / raw)
To: source
Log Message:
-----------
For .%R RFC, link to rfc-editor.org in -T markdown output
just like it was done for -T html in mdoc_html.c rev. 1.351.
Modified Files:
--------------
mandoc:
mdoc_markdown.c
mandoc/regress/mdoc/Rs:
rfc.out_markdown
Revision Data
-------------
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_markdown.c,v
diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.38 -r1.39
--- mdoc_markdown.c
+++ mdoc_markdown.c
@@ -1,6 +1,6 @@
/* $Id$ */
/*
- * Copyright (c) 2017, 2018, 2020 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2017, 2018, 2020, 2025 Ingo Schwarze <schwarze@openbsd.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -85,6 +85,7 @@ static int md_pre_Sh(struct roff_node *
static int md_pre_Sm(struct roff_node *);
static int md_pre_Vt(struct roff_node *);
static int md_pre_Xr(struct roff_node *);
+static int md_pre__R(struct roff_node *);
static int md_pre__T(struct roff_node *);
static int md_pre_br(struct roff_node *);
@@ -159,7 +160,7 @@ static const struct md_act md_acts[MDOC_
{ NULL, NULL, md_post_pc, NULL, NULL }, /* %N */
{ NULL, NULL, md_post_pc, NULL, NULL }, /* %O */
{ NULL, NULL, md_post_pc, NULL, NULL }, /* %P */
- { NULL, NULL, md_post_pc, NULL, NULL }, /* %R */
+ { NULL, md_pre__R, md_post_pc, NULL, NULL }, /* %R */
{ NULL, md_pre__T, md_post__T, NULL, NULL }, /* %T */
{ NULL, NULL, md_post_pc, NULL, NULL }, /* %V */
{ NULL, NULL, NULL, NULL, NULL }, /* Ac */
@@ -1577,6 +1578,34 @@ md_pre_Xr(struct roff_node *n)
md_word("(");
md_node(n);
md_word(")");
+ return 0;
+}
+
+static int
+md_pre__R(struct roff_node *n)
+{
+ const unsigned char *cp;
+ const char *arg;
+
+ arg = n->child->string;
+
+ if (strncmp(arg, "RFC ", 4) != 0)
+ return 1;
+ cp = arg += 4;
+ while (isdigit(*cp))
+ cp++;
+ if (*cp != '\0')
+ return 1;
+
+ md_rawword("[RFC ");
+ outflags &= ~MD_spc;
+ md_rawword(arg);
+ outflags &= ~MD_spc;
+ md_rawword("](http://www.rfc-editor.org/rfc/rfc");
+ outflags &= ~MD_spc;
+ md_rawword(arg);
+ outflags &= ~MD_spc;
+ md_rawword(".html)");
return 0;
}
Index: rfc.out_markdown
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/rfc.out_markdown,v
diff -Lregress/mdoc/Rs/rfc.out_markdown -Lregress/mdoc/Rs/rfc.out_markdown -u -p -r1.1 -r1.2
--- regress/mdoc/Rs/rfc.out_markdown
+++ regress/mdoc/Rs/rfc.out_markdown
@@ -10,7 +10,7 @@ BEGINTEST
David Waitzman,
*A Standard for the Transmission of IP Datagrams on Avian Carriers*,
-RFC 1149,
+[RFC 1149](http://www.rfc-editor.org/rfc/rfc1149.html),
April 1990.
ENDTEST
--
To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-20 7:01 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-20 7:01 mandoc: For .%R RFC, link to rfc-editor.org in -T markdown output just schwarze
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).