source@mandoc.bsd.lv
 help / color / mirror / Atom feed
From: schwarze@mandoc.bsd.lv
To: source@mandoc.bsd.lv
Subject: mandoc: Formatting of the .%T (title) macro needs some logic to adhere
Date: Fri, 24 Jan 2025 23:36:24 +0000 (UTC)	[thread overview]
Message-ID: <12bbce5847bb14f9@mandoc.bsd.lv> (raw)

Log Message:
-----------
Formatting of the .%T (title) macro needs some logic to adhere to
traditional typographic conventions that are already implemented for
terminal output: set titles of independent works (like books or RFCs)
in italic and of parts of larger works (like journal articles)
in quotation marks and roman font.  Do that in HTML output, too.

OK job@ (without the regress parts),
and tb@ appears to agree with the general direction

Modified Files:
--------------
    mandoc:
        mandoc.css
        mdoc_html.c
    mandoc/regress/mdoc/Rs:
        Makefile
        rfc.out_html

Added Files:
-----------
    mandoc/regress/mdoc/Rs:
        journal.in
        journal.out_ascii
        journal.out_html
        journal.out_markdown
        outside.in
        outside.out_ascii
        outside.out_html
        outside.out_markdown

Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mdoc_html.c,v
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.351 -r1.352
--- mdoc_html.c
+++ mdoc_html.c
@@ -1555,7 +1555,13 @@ mdoc__x_pre(MDOC_ARGS)
 		cattr = "RsR";
 		break;
 	case MDOC__T:
-		cattr = "RsT";
+		if (n->parent != NULL && n->parent->tok == MDOC_Rs &&
+		    n->parent->norm->Rs.quote_T) {
+			print_text(h, "\\(lq");
+			h->flags |= HTML_NOSPACE;
+			cattr = "RsT";
+		} else
+			cattr = "RsB";
 		break;
 	case MDOC__U:
 		print_otag(h, TAG_A, "ch", "RsU", arg);
@@ -1576,14 +1582,23 @@ mdoc__x_post(MDOC_ARGS)
 {
 	struct roff_node *nn;
 
-	if (n->tok == MDOC__A &&
-	    (nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A &&
-	    ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) &&
-	    ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A))
-		return;
-
-	/* TODO: %U */
-
+	switch (n->tok) {
+	case MDOC__A:
+		if ((nn = roff_node_next(n)) != NULL && nn->tok == MDOC__A &&
+		    ((nn = roff_node_next(nn)) == NULL || nn->tok != MDOC__A) &&
+		    ((nn = roff_node_prev(n)) == NULL || nn->tok != MDOC__A))
+			return;
+		break;
+	case MDOC__T:
+		if (n->parent != NULL && n->parent->tok == MDOC_Rs &&
+		    n->parent->norm->Rs.quote_T) {
+			h->flags |= HTML_NOSPACE;
+			print_text(h, "\\(rq");
+		}
+		break;
+	default:
+		break;
+	}
 	if (n->parent == NULL || n->parent->tok != MDOC_Rs)
 		return;
 
Index: mandoc.css
===================================================================
RCS file: /home/cvs/mandoc/mandoc/mandoc.css,v
diff -Lmandoc.css -Lmandoc.css -u -p -r1.52 -r1.53
--- mandoc.css
+++ mandoc.css
@@ -179,7 +179,7 @@ h3.Ss {		margin-top: 1.2em;
 .RsP { }
 .RsQ { }
 .RsR { }
-.RsT {		text-decoration: underline; }
+.RsT { }
 .RsU { }
 .RsV { }
 
Index: Makefile
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/Makefile,v
diff -Lregress/mdoc/Rs/Makefile -Lregress/mdoc/Rs/Makefile -u -p -r1.7 -r1.8
--- regress/mdoc/Rs/Makefile
+++ regress/mdoc/Rs/Makefile
@@ -1,9 +1,10 @@
-# $OpenBSD: Makefile,v 1.13 2025/01/19 23:01:27 schwarze Exp $
+# $OpenBSD: Makefile,v 1.14 2025/01/24 23:22:13 schwarze Exp $
 
-REGRESS_TARGETS	 = allch args break empty paragraph three_authors rfc transp
+REGRESS_TARGETS	 = allch args break empty journal outside paragraph
+REGRESS_TARGETS	+= rfc three_authors transp
 UTF8_TARGETS	 = allch break empty three_authors
 LINT_TARGETS	 = allch args empty
-HTML_TARGETS	 = paragraph rfc
+HTML_TARGETS	 = journal outside paragraph rfc
 
 # groff-1.22.3 defect:
 # - arguments after .Rs cause the macro to be ignored
--- /dev/null
+++ regress/mdoc/Rs/journal.out_markdown
@@ -0,0 +1,21 @@
+RS-JOURNAL(1) - General Commands Manual
+
+# NAME
+
+**Rs-journal** - reference to a journal article
+
+# DESCRIPTION
+
+BEGINTEST
+
+Brian W. Kernighan,
+Lorinda L. Cherry,
+"System for Typesetting Mathematics",
+*Communications of the ACM*,
+18,
+pp. 151&#8211;157,
+March 1975.
+
+ENDTEST
+
+OpenBSD - January 24, 2025
Index: rfc.out_html
===================================================================
RCS file: /home/cvs/mandoc/mandoc/regress/mdoc/Rs/rfc.out_html,v
diff -Lregress/mdoc/Rs/rfc.out_html -Lregress/mdoc/Rs/rfc.out_html -u -p -r1.1 -r1.2
--- regress/mdoc/Rs/rfc.out_html
+++ regress/mdoc/Rs/rfc.out_html
@@ -1,5 +1,5 @@
 <p class="Pp"><cite class="Rs"><span class="RsA">David Waitzman</span>,
-    <span class="RsT">A Standard for the Transmission of IP Datagrams on Avian
+    <span class="RsB">A Standard for the Transmission of IP Datagrams on Avian
     Carriers</span>,
     <a class="RsR" href="https://www.rfc-editor.org/rfc/rfc1149.html">RFC
     1149</a>, <span class="RsD">April 1990</span>.</cite></p>
--- /dev/null
+++ regress/mdoc/Rs/outside.out_html
@@ -0,0 +1,4 @@
+<p class="Pp">Some percent-macros can be used outside reference blocks. For
+    example, let's study <i class="RsB">The Book of PF</i> and relax reading
+    <span class="RsB">A Standard for the Transmission of IP Datagrams on Avian
+    Carriers</span> afterwards.</p>
--- /dev/null
+++ regress/mdoc/Rs/journal.out_ascii
@@ -0,0 +1,14 @@
+RS-JOURNAL(1)               General Commands Manual              RS-JOURNAL(1)
+
+N\bNA\bAM\bME\bE
+     R\bRs\bs-\b-j\bjo\bou\bur\brn\bna\bal\bl - reference to a journal article
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     BEGINTEST
+
+     Brian W. Kernighan and Lorinda L. Cherry, "System for Typesetting
+     Mathematics", _\bC_\bo_\bm_\bm_\bu_\bn_\bi_\bc_\ba_\bt_\bi_\bo_\bn_\bs _\bo_\bf _\bt_\bh_\be _\bA_\bC_\bM, 18, pp. 151-157, March 1975.
+
+     ENDTEST
+
+OpenBSD                        January 24, 2025                        OpenBSD
--- /dev/null
+++ regress/mdoc/Rs/outside.in
@@ -0,0 +1,18 @@
+.\" $OpenBSD: outside.in,v 1.1 2025/01/24 23:22:13 schwarze Exp $
+.Dd $Mdocdate: January 24 2025 $
+.Dt RS-OUTSIDE 1
+.Os
+.Sh NAME
+.Nm Rs-outside
+.Nd reference macros outside reference blocks
+.Sh DESCRIPTION
+BEGINTEST
+.Pp
+Some percent-macros can be used outside reference blocks.
+For example, let's study
+.%B The Book of PF
+and relax reading
+.%T A Standard for the Transmission of IP Datagrams on Avian Carriers
+afterwards.
+.Pp
+ENDTEST
--- /dev/null
+++ regress/mdoc/Rs/journal.out_html
@@ -0,0 +1,5 @@
+<p class="Pp"><cite class="Rs"><span class="RsA">Brian W. Kernighan</span> and
+    <span class="RsA">Lorinda L. Cherry</span>, &#x201C;<span class="RsT">System
+    for Typesetting Mathematics</span>&#x201D;, <i class="RsJ">Communications of
+    the ACM</i>, <span class="RsV">18</span>, <span class="RsP">pp.
+    151&#x2013;157</span>, <span class="RsD">March 1975</span>.</cite></p>
--- /dev/null
+++ regress/mdoc/Rs/outside.out_ascii
@@ -0,0 +1,15 @@
+RS-OUTSIDE(1)               General Commands Manual              RS-OUTSIDE(1)
+
+N\bNA\bAM\bME\bE
+     R\bRs\bs-\b-o\bou\but\bts\bsi\bid\bde\be - reference macros outside reference blocks
+
+D\bDE\bES\bSC\bCR\bRI\bIP\bPT\bTI\bIO\bON\bN
+     BEGINTEST
+
+     Some percent-macros can be used outside reference blocks.  For example,
+     let's study _\bT_\bh_\be _\bB_\bo_\bo_\bk _\bo_\bf _\bP_\bF and relax reading _\bA _\bS_\bt_\ba_\bn_\bd_\ba_\br_\bd _\bf_\bo_\br _\bt_\bh_\be
+     _\bT_\br_\ba_\bn_\bs_\bm_\bi_\bs_\bs_\bi_\bo_\bn _\bo_\bf _\bI_\bP _\bD_\ba_\bt_\ba_\bg_\br_\ba_\bm_\bs _\bo_\bn _\bA_\bv_\bi_\ba_\bn _\bC_\ba_\br_\br_\bi_\be_\br_\bs afterwards.
+
+     ENDTEST
+
+OpenBSD                        January 24, 2025                        OpenBSD
--- /dev/null
+++ regress/mdoc/Rs/journal.in
@@ -0,0 +1,21 @@
+.\" $OpenBSD: journal.in,v 1.1 2025/01/24 23:22:13 schwarze Exp $
+.Dd $Mdocdate: January 24 2025 $
+.Dt RS-JOURNAL 1
+.Os
+.Sh NAME
+.Nm Rs-journal
+.Nd reference to a journal article
+.Sh DESCRIPTION
+BEGINTEST
+.Pp
+.Rs
+.%A Brian W. Kernighan
+.%A Lorinda L. Cherry
+.%T System for Typesetting Mathematics
+.%J Communications of the ACM
+.%V 18
+.%P pp. 151\(en157
+.%D March 1975
+.Re
+.Pp
+ENDTEST
--- /dev/null
+++ regress/mdoc/Rs/outside.out_markdown
@@ -0,0 +1,20 @@
+RS-OUTSIDE(1) - General Commands Manual
+
+# NAME
+
+**Rs-outside** - reference macros outside reference blocks
+
+# DESCRIPTION
+
+BEGINTEST
+
+Some percent-macros can be used outside reference blocks.
+For example, let's study
+*The Book of PF*
+and relax reading
+*A Standard for the Transmission of IP Datagrams on Avian Carriers*
+afterwards.
+
+ENDTEST
+
+OpenBSD - January 24, 2025
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


                 reply	other threads:[~2025-01-24 23:36 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=12bbce5847bb14f9@mandoc.bsd.lv \
    --to=schwarze@mandoc.bsd.lv \
    --cc=source@mandoc.bsd.lv \
    /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).