groff-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[groff] 01/01: [mdoc]: rewrite the implementation of the .Lk macro


From: Ingo Schwarze
Subject: [groff] 01/01: [mdoc]: rewrite the implementation of the .Lk macro
Date: Fri, 12 Jan 2018 21:57:56 -0500 (EST)

schwarze pushed a commit to branch master
in repository groff.

commit e53dff356d43f358133138d2f99eca7b0a7fda32
Author: Ingo Schwarze <address@hidden>
Date:   Sat Jan 13 03:50:59 2018 +0100

    [mdoc]: rewrite the implementation of the .Lk macro
    
    * tmac/doc.tmac-u (Lk): Rewrite.
    
    The old implementation was written before the big mdoc
    rewrite for groff-1.17.  In contrast to most other macros,
    it was never updated to use the new techniques.
    This new implementation makes .Lk callable, makes trailing
    punctuation work in the normal way, and makes the style of
    the implementation consistent with other macros.
    
    It also removes the feature of automatically switching
    between in-line and displayed rendering depending on the
    length of the link because that was inconsistent across
    output modes and counter-intuitive, resulting in ugly
    output for many existing real-world manual pages.
    It now always renders in-line.  Use .D1 Lk where desired.
    
    Merging http://savannah.gnu.org/bugs/?52849
    OK address@hidden, address@hidden, address@hidden
---
 ChangeLog       | 23 ++++++++++++++++
 tmac/doc.tmac-u | 82 +++++++++++++++++++++++++++++++--------------------------
 2 files changed, 68 insertions(+), 37 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 090e286..e574fba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2018-01-13  Ingo Schwarze <address@hidden>
+
+       [mdoc]: rewrite the implementation of the .Lk macro
+
+       * tmac/doc.tmac-u (Lk): Rewrite.
+
+       The old implementation was written before the big mdoc
+       rewrite for groff-1.17.  In contrast to most other macros,
+       it was never updated to use the new techniques.
+       This new implementation makes .Lk callable, makes trailing
+       punctuation work in the normal way, and makes the style of
+       the implementation consistent with other macros.
+
+       It also removes the feature of automatically switching
+       between in-line and displayed rendering depending on the
+       length of the link because that was inconsistent across
+       output modes and counter-intuitive, resulting in ugly
+       output for many existing real-world manual pages.
+       It now always renders in-line.  Use .D1 Lk where desired.
+
+       Merging http://savannah.gnu.org/bugs/?52849
+       OK address@hidden, address@hidden, address@hidden
+
 2017-12-14  G. Branden Robinson <address@hidden>
 
        man pages: Comment compatibility-mode switching.
diff --git a/tmac/doc.tmac-u b/tmac/doc.tmac-u
index 166f207..f172fd8 100644
--- a/tmac/doc.tmac-u
+++ b/tmac/doc.tmac-u
@@ -6447,54 +6447,62 @@
 .\" NS Lk user macro
 .\" NS   link (for conversion to HTML)
 .\" NS
+.\" NS modifies:
+.\" NS   doc-arg-ptr
+.\" NS   doc-curr-font
+.\" NS   doc-curr-size
+.\" NS   doc-macro-name
+.\" NS
 .\" NS local variables:
-.\" NS   doc-delim-Lk
-.\" NS   doc-reg-Lk
+.\" NS   doc-lasttext-Lk
 .\" NS   doc-target-Lk
-.\" NS   doc-text-Lk
 .
 .de Lk
+.  if !\n[doc-arg-limit] \{\
+.    ds doc-macro-name Lk
+.    doc-parse-args \$@
+.  \}
+.
+.  if !\n[doc-arg-limit] \
+.    return
+.
 .  \" The first argument is the target URI.
-.  ds doc-target-Lk \$1
-.  shift
+.  nr doc-arg-ptr +1
+.  ds doc-target-Lk "\*[doc-arg\n[doc-arg-ptr]]
+.  nr doc-arg-ptr +1
 .
-.  \" Split the remaining arguments into link text and delimiters.
-.  ds doc-text-Lk
-.  ds doc-delim-Lk
-.  while \n[.$] \{\
-.    doc-get-width "\$1"
-.    doc-get-arg-type \$1
-.    ie (\n[doc-arg-type] > 2) \
-.      as doc-delim-Lk \$1
-.    el \{\
-.      if !'\*[doc-delim-Lk]'' \{\
-.        \" More text follows delimiter(s); go back to text mode.
-.        as doc-text-Lk \*[doc-delim-Lk]
-.        ds doc-delim-Lk
-.      \}
-.      ie '\*[doc-text-Lk]'' \
-.        ds doc-text-Lk \$1
-.      el \
-.        as doc-text-Lk " \$1
-.    \}
-.    shift
+.  \" Search backwards for the first closing punctuation.
+.  nr doc-lasttext-Lk \n[doc-arg-limit]
+.  while (\n[doc-lasttext-Lk] >= \n[doc-arg-ptr]) \{\
+.    if !(\n[doc-type\n[doc-lasttext-Lk]] == 3) \
+.      break
+.    nr doc-lasttext-Lk -1
 .  \}
 .
 .  \" Print the link text, if any.
-.  if !'\*[doc-text-Lk]'' \
-.      Em \*[doc-text-Lk] Ns :
+.  nr doc-curr-font \n[.f]
+.  nr doc-curr-size \n[.ps]
+.  if (\n[doc-arg-ptr] <= \n[doc-lasttext-Lk]) \{\
+.    nop \*[doc-Em-font]\c
+.    while (\n[doc-arg-ptr] < \n[doc-lasttext-Lk]) \{\
+.      nop \*[doc-arg\n[doc-arg-ptr]]
+.      nr doc-arg-ptr +1
+.    \}
+.    nop \*[doc-arg\n[doc-arg-ptr]]\f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]:
+.    nr doc-arg-ptr +1
+.  \}
 .
 .  \" Print the link target.
-.  ie n \
-.    nr doc-reg-Lk 26
-.  el \
-.    nr doc-reg-Lk 38
-.  doc-get-width "\*[doc-target-Lk]"
-.  ie (\n[doc-width] >= \n[doc-reg-Lk]) \
-.    D1 Sy \*[doc-target-Lk] Ns \*[doc-delim-Lk]\&
-.  el .ie \n[doc-width] \
-.    Sy \*[doc-target-Lk] Ns \*[doc-delim-Lk]\&
-.  el \*[doc-delim-Lk]\&
+.  nop \*[doc-Sy-font]\*[doc-target-Lk]\c
+.  nop \f[\n[doc-curr-font]]\s[\n[doc-curr-size]u]\c
+.
+.  \" Print the delimiters, if any.
+.  while (\n[doc-arg-ptr] <= \n[doc-arg-limit]) \{\
+.    nop \*[doc-arg\n[doc-arg-ptr]]\c
+.    nr doc-arg-ptr +1
+.  \}
+.  nop \&
+.  doc-reset-args
 ..
 .
 .



reply via email to

[Prev in Thread] Current Thread [Next in Thread]