From: Kristaps Dzonsons <kristaps@bsd.lv>
To: discuss@mdocml.bsd.lv
Subject: Re: desired .Bk semantics? [UPDATED PATCH]
Date: Sat, 03 Jul 2010 19:25:38 +0200 [thread overview]
Message-ID: <4C2F7292.7050507@bsd.lv> (raw)
In-Reply-To: <20100703165249.GH20174@bramka.kerhand.co.uk>
[-- Attachment #1: Type: text/plain, Size: 753 bytes --]
> spiffing!
>
> i wonder though about disabling Bk...do you mean it just ignores it, or
> that the current Bk/Ek in files will cause a problem? i'm not averse to
> removing them from pages, but i need to think about our pages being
> formatted on another system. for example, for ssh.1 to have a fighting
> chance on a non-mandoc system.
>
> i don;t know how practical that is though. i haven;t thought very far
> ahead about this. keep the keeps (er) or remove them...
Here's an updated version of the patch that also addresses `Fn' and `Fa'.
It also correctly uses TERMP_PREKEEP instead of TERMP_KEEP, and dips
into encode() to transcode quoted whitespace into ASCII_NBRSP (such as
the case of `Fa "foo bar"').
Ingo, what do you think?
Kristaps
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 4878 bytes --]
? .mdoc.3.swp
? config.h
? config.log
? foo.1
? foo.1.html
? foo.3
? foo.7
? foo.html
? mandoc
? patch.txt
? relayd.8
? relayd.8.html
? spamd.8
? ssh.1
? ssh.1.html
? regress/output
Index: mdoc_term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/mdoc_term.c,v
retrieving revision 1.169
diff -u -r1.169 mdoc_term.c
--- mdoc_term.c 3 Jul 2010 17:17:15 -0000 1.169
+++ mdoc_term.c 3 Jul 2010 17:25:45 -0000
@@ -72,14 +72,13 @@
static void termp_an_post(DECL_ARGS);
static void termp_aq_post(DECL_ARGS);
static void termp_bd_post(DECL_ARGS);
-static void termp_bk_post(DECL_ARGS);
static void termp_bl_post(DECL_ARGS);
static void termp_bq_post(DECL_ARGS);
static void termp_brq_post(DECL_ARGS);
static void termp_bx_post(DECL_ARGS);
static void termp_d1_post(DECL_ARGS);
static void termp_dq_post(DECL_ARGS);
-static int termp_fd_pre(DECL_ARGS);
+static void termp_fa_post(DECL_ARGS);
static void termp_fo_post(DECL_ARGS);
static void termp_in_post(DECL_ARGS);
static void termp_it_post(DECL_ARGS);
@@ -98,7 +97,6 @@
static int termp_aq_pre(DECL_ARGS);
static int termp_bd_pre(DECL_ARGS);
static int termp_bf_pre(DECL_ARGS);
-static int termp_bk_pre(DECL_ARGS);
static int termp_bl_pre(DECL_ARGS);
static int termp_bold_pre(DECL_ARGS);
static int termp_bq_pre(DECL_ARGS);
@@ -109,6 +107,7 @@
static int termp_dq_pre(DECL_ARGS);
static int termp_ex_pre(DECL_ARGS);
static int termp_fa_pre(DECL_ARGS);
+static int termp_fd_pre(DECL_ARGS);
static int termp_fl_pre(DECL_ARGS);
static int termp_fn_pre(DECL_ARGS);
static int termp_fo_pre(DECL_ARGS);
@@ -161,10 +160,10 @@
{ NULL, NULL }, /* Er */
{ NULL, NULL }, /* Ev */
{ termp_ex_pre, NULL }, /* Ex */
- { termp_fa_pre, NULL }, /* Fa */
+ { termp_fa_pre, termp_fa_post }, /* Fa */
{ termp_fd_pre, NULL }, /* Fd */
{ termp_fl_pre, NULL }, /* Fl */
- { termp_fn_pre, NULL }, /* Fn */
+ { termp_fn_pre, termp_fa_post }, /* Fn */
{ termp_ft_pre, NULL }, /* Ft */
{ termp_bold_pre, NULL }, /* Ic */
{ termp_in_pre, termp_in_post }, /* In */
@@ -238,7 +237,7 @@
{ NULL, NULL }, /* Fc */
{ termp_op_pre, termp_op_post }, /* Oo */
{ NULL, NULL }, /* Oc */
- { termp_bk_pre, termp_bk_post }, /* Bk */
+ { NULL, NULL }, /* Bk */
{ NULL, NULL }, /* Ek */
{ termp_bt_pre, NULL }, /* Bt */
{ NULL, NULL }, /* Hf */
@@ -1279,6 +1278,8 @@
if (MDOC_BODY != n->type)
return;
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
p->flags |= TERMP_NOSPACE;
term_word(p, "\\(rB");
}
@@ -1460,6 +1461,8 @@
case (MDOC_BODY):
term_word(p, "\\(lB");
p->flags |= TERMP_NOSPACE;
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags |= TERMP_PREKEEP;
break;
default:
break;
@@ -1578,7 +1581,13 @@
for (nn = n->child->next; nn; nn = nn->next) {
term_fontpush(p, TERMFONT_UNDER);
+
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags |= TERMP_PREKEEP;
term_word(p, nn->string);
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+
term_fontpop(p);
if (nn->next)
@@ -1602,12 +1611,20 @@
if (n->parent->tok != MDOC_Fo) {
term_fontpush(p, TERMFONT_UNDER);
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags |= TERMP_PREKEEP;
return(1);
}
for (nn = n->child; nn; nn = nn->next) {
term_fontpush(p, TERMFONT_UNDER);
+
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags |= TERMP_PREKEEP;
term_word(p, nn->string);
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+
term_fontpop(p);
if (nn->next)
@@ -1622,6 +1639,16 @@
/* ARGSUSED */
+static void
+termp_fa_post(DECL_ARGS)
+{
+
+ if (MDOC_SYNPRETTY & n->flags)
+ p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
+}
+
+
+/* ARGSUSED */
static int
termp_bd_pre(DECL_ARGS)
{
@@ -2140,37 +2167,6 @@
return(0);
}
-
-/* ARGSUSED */
-static int
-termp_bk_pre(DECL_ARGS)
-{
-
- switch (n->type) {
- case (MDOC_BLOCK):
- break;
- case (MDOC_HEAD):
- return(0);
- case (MDOC_BODY):
- p->flags |= TERMP_PREKEEP;
- break;
- default:
- abort();
- /* NOTREACHED */
- }
-
- return(1);
-}
-
-
-/* ARGSUSED */
-static void
-termp_bk_post(DECL_ARGS)
-{
-
- if (MDOC_BODY == n->type)
- p->flags &= ~(TERMP_KEEP | TERMP_PREKEEP);
-}
/* ARGSUSED */
static int
Index: term.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/term.c,v
retrieving revision 1.158
diff -u -r1.158 term.c
--- term.c 3 Jul 2010 16:02:12 -0000 1.158
+++ term.c 3 Jul 2010 17:25:45 -0000
@@ -624,7 +624,11 @@
for (i = 0; i < (int)sz; i++) {
if ( ! isgraph((u_char)word[i])) {
- bufferc(p, word[i]);
+ if (TERMP_KEEP & p->flags && ' ' == word[i])
+ bufferc(p, ASCII_NBRSP);
+ else
+ bufferc(p, word[i]);
+
continue;
}
next prev parent reply other threads:[~2010-07-03 17:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-02 23:43 desired .Bk semantics? Ingo Schwarze
2010-07-03 6:54 ` Jason McIntyre
2010-07-03 12:27 ` Kristaps Dzonsons
2010-07-03 14:11 ` Jason McIntyre
2010-07-03 16:24 ` Kristaps Dzonsons
2010-07-03 16:52 ` Jason McIntyre
2010-07-03 17:25 ` Kristaps Dzonsons [this message]
2010-07-03 17:28 ` Ingo Schwarze
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=4C2F7292.7050507@bsd.lv \
--to=kristaps@bsd.lv \
--cc=discuss@mdocml.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).