* mdocml: fix formatting of intermediate punctuation in .Lk
@ 2017-05-30 16:31 schwarze
0 siblings, 0 replies; only message in thread
From: schwarze @ 2017-05-30 16:31 UTC (permalink / raw)
To: source
Log Message:
-----------
fix formatting of intermediate punctuation in .Lk
Modified Files:
--------------
mdocml:
mdoc_html.c
mdoc_man.c
mdoc_markdown.c
mdoc_term.c
mdocml/regress/mdoc/Lk:
noarg.in
Revision Data
-------------
Index: mdoc_html.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_html.c,v
retrieving revision 1.288
retrieving revision 1.289
diff -Lmdoc_html.c -Lmdoc_html.c -u -p -r1.288 -r1.289
--- mdoc_html.c
+++ mdoc_html.c
@@ -1309,24 +1309,32 @@ mdoc_pp_pre(MDOC_ARGS)
static int
mdoc_lk_pre(MDOC_ARGS)
{
+ const struct roff_node *link, *descr, *punct;
struct tag *t;
- if ((n = n->child) == NULL)
+ if ((link = n->child) == NULL)
return 0;
+ /* Find beginning of trailing punctuation. */
+ punct = n->last;
+ while (punct != link && punct->flags & NODE_DELIMC)
+ punct = punct->prev;
+ punct = punct->next;
+
/* Link target and link text. */
- t = print_otag(h, TAG_A, "cTh", "Lk", n->string);
- if (n->next == NULL || n->next->flags & NODE_DELIMC)
- print_text(h, n->string);
- for (n = n->next; n != NULL && !(n->flags & NODE_DELIMC); n = n->next)
- print_text(h, n->string);
+ t = print_otag(h, TAG_A, "cTh", "Lk", link->string);
+ for (descr = link->next; descr != punct; descr = descr->next) {
+ if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
+ h->flags |= HTML_NOSPACE;
+ print_text(h, descr->string);
+ }
print_tagq(h, t);
/* Trailing punctuation. */
- while (n != NULL) {
+ while (punct != NULL) {
h->flags |= HTML_NOSPACE;
- print_text(h, n->string);
- n = n->next;
+ print_text(h, punct->string);
+ punct = punct->next;
}
return 0;
}
Index: mdoc_man.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_man.c,v
retrieving revision 1.115
retrieving revision 1.116
diff -Lmdoc_man.c -Lmdoc_man.c -u -p -r1.115 -r1.116
--- mdoc_man.c
+++ mdoc_man.c
@@ -1527,16 +1527,22 @@ post_lb(DECL_ARGS)
static int
pre_lk(DECL_ARGS)
{
- const struct roff_node *link, *descr;
+ const struct roff_node *link, *descr, *punct;
int display;
if ((link = n->child) == NULL)
return 0;
+ /* Find beginning of trailing punctuation. */
+ punct = n->last;
+ while (punct != link && punct->flags & NODE_DELIMC)
+ punct = punct->prev;
+ punct = punct->next;
+
/* Link text. */
- if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) {
+ if ((descr = link->next) != NULL && descr != punct) {
font_push('I');
- while (descr != NULL && !(descr->flags & NODE_DELIMC)) {
+ while (descr != punct) {
print_word(descr->string);
descr = descr->next;
}
@@ -1556,9 +1562,9 @@ pre_lk(DECL_ARGS)
font_pop();
/* Trailing punctuation. */
- while (descr != NULL) {
- print_word(descr->string);
- descr = descr->next;
+ while (punct != NULL) {
+ print_word(punct->string);
+ punct = punct->next;
}
if (display)
print_line(".RE", MMAN_nl);
Index: mdoc_markdown.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_markdown.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -Lmdoc_markdown.c -Lmdoc_markdown.c -u -p -r1.21 -r1.22
--- mdoc_markdown.c
+++ mdoc_markdown.c
@@ -1306,21 +1306,27 @@ md_uri(const char *s)
static int
md_pre_Lk(struct roff_node *n)
{
- const struct roff_node *link, *descr;
+ const struct roff_node *link, *descr, *punct;
if ((link = n->child) == NULL)
return 0;
+ /* Find beginning of trailing punctuation. */
+ punct = n->last;
+ while (punct != link && punct->flags & NODE_DELIMC)
+ punct = punct->prev;
+ punct = punct->next;
+
/* Link text. */
descr = link->next;
- if (descr == NULL || descr->flags & NODE_DELIMC)
+ if (descr == punct)
descr = link; /* no text */
md_rawword("[");
outflags &= ~MD_spc;
do {
md_word(descr->string);
descr = descr->next;
- } while (descr != NULL && !(descr->flags & NODE_DELIMC));
+ } while (descr != punct);
outflags &= ~MD_spc;
/* Link target. */
@@ -1330,9 +1336,9 @@ md_pre_Lk(struct roff_node *n)
md_rawword(")");
/* Trailing punctuation. */
- while (descr != NULL) {
- md_word(descr->string);
- descr = descr->next;
+ while (punct != NULL) {
+ md_word(punct->string);
+ punct = punct->next;
}
return 0;
}
Index: mdoc_term.c
===================================================================
RCS file: /home/cvs/mdocml/mdocml/mdoc_term.c,v
retrieving revision 1.357
retrieving revision 1.358
diff -Lmdoc_term.c -Lmdoc_term.c -u -p -r1.357 -r1.358
--- mdoc_term.c
+++ mdoc_term.c
@@ -1977,16 +1977,24 @@ termp_li_pre(DECL_ARGS)
static int
termp_lk_pre(DECL_ARGS)
{
- const struct roff_node *link, *descr;
+ const struct roff_node *link, *descr, *punct;
int display;
if ((link = n->child) == NULL)
return 0;
+ /* Find beginning of trailing punctuation. */
+ punct = n->last;
+ while (punct != link && punct->flags & NODE_DELIMC)
+ punct = punct->prev;
+ punct = punct->next;
+
/* Link text. */
- if ((descr = link->next) != NULL && !(descr->flags & NODE_DELIMC)) {
+ if ((descr = link->next) != NULL && descr != punct) {
term_fontpush(p, TERMFONT_UNDER);
- while (descr != NULL && !(descr->flags & NODE_DELIMC)) {
+ while (descr != punct) {
+ if (descr->flags & (NODE_DELIMC | NODE_DELIMO))
+ p->flags |= TERMP_NOSPACE;
term_word(p, descr->string);
descr = descr->next;
}
@@ -2006,10 +2014,10 @@ termp_lk_pre(DECL_ARGS)
term_fontpop(p);
/* Trailing punctuation. */
- while (descr != NULL) {
+ while (punct != NULL) {
p->flags |= TERMP_NOSPACE;
- term_word(p, descr->string);
- descr = descr->next;
+ term_word(p, punct->string);
+ punct = punct->next;
}
if (display)
term_newln(p);
Index: noarg.in
===================================================================
RCS file: /home/cvs/mdocml/mdocml/regress/mdoc/Lk/noarg.in,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lregress/mdoc/Lk/noarg.in -Lregress/mdoc/Lk/noarg.in -u -p -r1.2 -r1.3
--- regress/mdoc/Lk/noarg.in
+++ regress/mdoc/Lk/noarg.in
@@ -7,7 +7,7 @@
.Sh DESCRIPTION
multiple arguments
.Lk http://www.bsd.lv/ the bsd.lv project ,
-.Lk http://www.gnu.org/software/groff/ GNU troff ,
+.Lk http://www.gnu.org/software/groff/ GNU troff ","
two arguments
.Lk http://mdocml.bsd.lv/ mandoc
one argument
--
To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-05-30 16:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 16:31 mdocml: fix formatting of intermediate punctuation in .Lk 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).