SF.net SVN: docutils:[10109 ] trunk

grubert--- via Docutils-checkins <[email protected]> Fri, 25 Apr 2025 16:21:30 +0000
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 10109
          http://sourceforge.net/p/docutils/code/10109
Author:   grubert
Date:     2025-04-25 16:21:29 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
manpage writer
- macro-references: insert breakpoints and hyphenation-off.
- iskip reference content if content is equal, or only differs
    by "mailto:".

Modified Paths:
--------------
    trunk/docutils/HISTORY.rst
    trunk/docutils/docutils/writers/manpage.py
    trunk/sandbox/manpage-writer/expected/ref-2025-urue.man
    trunk/sandbox/manpage-writer/expected/refs-urue.man
    trunk/sandbox/manpage-writer/expected/refs-urue.utf8
    trunk/sandbox/manpage-writer/expected-mandoc/ref-2025-urue.utf8
    trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.man
    trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.ps
    trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.utf8

Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/docutils/HISTORY.rst	2025-04-25 16:21:29 UTC (rev 10109)
@@ -228,6 +228,9 @@
   - Use .MT/.ME macros for mailto.uris.
   - macro-references: output refuri always.
   - macro-references: reduce space around refs.
+  - macro-references: insert breakpoints and hyphenation-off.
+  - macro-references: Skip content if content is equal, or only differs
+    by "mailto:".
   - text-references: insert breakpoints and hyphenation-off.
   - text-references: no line end after refuri, no additional spaces.
   - text-references: Skip references only if content is equal, or only differs

Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/docutils/docutils/writers/manpage.py	2025-04-25 16:21:29 UTC (rev 10109)
@@ -1114,7 +1114,6 @@
 
     def _visit_reference_with_macro(self, node) -> None:
         # use UR/UE or MT/ME
-        # TODO insert_URI_breakpoints in text or refuri
         if 'refuri' in node:
             self.ensure_c_eol() # c_eol avoids space before the refuri
             _uri = node['refuri']
@@ -1127,10 +1126,14 @@
             else:
                 self.body.append(".UR ")
                 self.context.append('.UE\n')
-            self.body.append("%s\n" % _uri)
+            self.body.append("\\%%%s\n" % insert_URI_breakpoints(_uri))
+            if (node['refuri'] == node.astext()
+                or node['refuri'] == "mailto:"+node.astext()):
+                self.body.append(self.context.pop())
+                # if content is uri skip content
+                raise nodes.SkipNode
         else:
             self.context.append('')
-        # TODO if content is uri skip content
 
     def _depart_reference_with_macro(self, node) -> None:
         macro_end = self.context.pop()

Modified: trunk/sandbox/manpage-writer/expected/ref-2025-urue.man
===================================================================
--- trunk/sandbox/manpage-writer/expected/ref-2025-urue.man	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected/ref-2025-urue.man	2025-04-25 16:21:29 UTC (rev 10109)
@@ -34,28 +34,26 @@
 .\" from bugs#497
 .
 Aaaaa (\c
-.MT [email protected]
[email protected]
+.MT \%aaa@\:bb\:.ccc
 .ME \c
 ),
-.UR https://github.com/cc
+.UR \%https://\:github\:.com/cc
 Bbb
 .UE \c
  (\c
-.MT [email protected]
[email protected]
+.MT \%ddd@\:gmail\:.com
 .ME \c
 ).
-.UR https://github.com/m
+.UR \%https://\:github\:.com/m
 mm
 .UE
 .
-.UR https://github.com/nn
+.UR \%https://\:github\:.com/nn
 nn
 .UE
 .
 and \c
-.UR https://github.com/OooOoooo
+.UR \%https://\:github\:.com/\:OooOoooo
 OooOoooo
 .UE \c
 \&.

Modified: trunk/sandbox/manpage-writer/expected/refs-urue.man
===================================================================
--- trunk/sandbox/manpage-writer/expected/refs-urue.man	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected/refs-urue.man	2025-04-25 16:21:29 UTC (rev 10109)
@@ -99,13 +99,13 @@
 .SS External Hyperlink Targets
 .sp
 External hyperlinks, like \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
 \&.
 .sp
 embedded External hyperlinks, like \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
 \&.
@@ -116,11 +116,11 @@
 This is an example cross\-reference target.
 .SS Indirect Hyperlink Targets
 .sp
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
  is \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 my favourite
 programming language
 .UE \c
@@ -132,12 +132,12 @@
 .SH and
 .sp
 See the \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
  home page for info.
 .sp
-.MT [email protected]
+.MT \%jdoe@\:example\:.com
 Write to me
 .ME \c
  with your questions.
@@ -145,27 +145,22 @@
 .
 .SS URIs with known schemes
 .sp
-.UR tel:+48-816-555-1212
-tel:+48\-816\-555\-1212
+.UR \%tel:+48-816-555-1212
 .UE
 .
-.UR urn:isbn:0-486-27557-4
-urn:isbn:0\-486\-27557\-4
+.UR \%urn:isbn:0-486-27557-4
 .UE
 .
-.UR news:comp.infosystems.www.servers.unix
-news:comp.infosystems.www.servers.unix
+.UR \%news:comp\:.infosystems\:.www\:.servers\:.unix
 .UE
 .
-.UR https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
-https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
+.UR \%https://\:john\:.doe@\:www\:.example\:.com:123/\:forum/\:questions/?\:tag=networking&\:order=newest#\:top
 .UE
 .
 .SS Standalone email addresses
 .sp
 like \c
-.MT [email protected]
[email protected]
+.MT \%someone@\:somewhere\:.com
 .ME
 .
 .\" End of generated man page.

Modified: trunk/sandbox/manpage-writer/expected/refs-urue.utf8
===================================================================
--- trunk/sandbox/manpage-writer/expected/refs-urue.utf8	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected/refs-urue.utf8	2025-04-25 16:21:29 UTC (rev 10109)
@@ -76,9 +76,9 @@
        ]8;;mailto:[email protected]\Write to me]8;;\ with your questions.
 
    URIs with known schemes
-       ]8;;tel:+48-816-555-1212\tel:+48-816-555-1212]8;;\     ]8;;urn:isbn:0-486-27557-4\urn:isbn:0-486-27557-4]8;;\      ]8;;news:comp.infosystems.www.servers.unix\news:comp.infosys‐
-       tems.www.servers.unix]8;;\  ]8;;https://[email protected]:123/forum/questions/?tag=networking&order=newest#top\https://[email protected]:123/forum/ques‐
-       tions/?tag=network‐ ing&order=newest#top]8;;\
+       ]8;;tel:+48-816-555-1212\tel:+48-816-555-1212]8;;\  ]8;;urn:isbn:0-486-27557-4\urn:isbn:0-486-27557-4]8;;\  ]8;;news:comp.infosystems.www.servers.unix\news:comp.infosystems.www
+       .servers.unix]8;;\    ]8;;https://[email protected]:123/forum/questions/?tag=networking&order=newest#top\https://[email protected]:123/forum/questions/?
+       tag=networking&order=newest#top]8;;\
 
    Standalone email addresses
        like ]8;;mailto:[email protected]\[email protected]]8;;\

Modified: trunk/sandbox/manpage-writer/expected-mandoc/ref-2025-urue.utf8
===================================================================
--- trunk/sandbox/manpage-writer/expected-mandoc/ref-2025-urue.utf8	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected-mandoc/ref-2025-urue.utf8	2025-04-25 16:21:29 UTC (rev 10109)
@@ -1,8 +1,8 @@
 ()                                                                          ()
 
 NNaammee
-        - Aaaaa ([email protected] <[email protected]>), Bbb <https://github.com/cc>
-       ([email protected] <[email protected]>).  mm <https://github.com/m> nn
-       <https://github.com/nn> and OooOoooo <https://github.com/OooOoooo>.
+        - Aaaaa (<[email protected]>), Bbb <https://github.com/cc> (<[email protected]>).
+       mm <https://github.com/m> nn <https://github.com/nn> and OooOoooo
+       <https://github.com/OooOoooo>.
 
                                                                             ()

Modified: trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.man
===================================================================
--- trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.man	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.man	2025-04-25 16:21:29 UTC (rev 10109)
@@ -99,13 +99,13 @@
 .SS External Hyperlink Targets
 .sp
 External hyperlinks, like \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
 \&.
 .sp
 embedded External hyperlinks, like \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
 \&.
@@ -116,11 +116,11 @@
 This is an example cross\-reference target.
 .SS Indirect Hyperlink Targets
 .sp
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
  is \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 my favourite
 programming language
 .UE \c
@@ -132,12 +132,12 @@
 .SH and
 .sp
 See the \c
-.UR https://www.python.org/
+.UR \%https://\:www\:.python\:.org/
 Python
 .UE \c
  home page for info.
 .sp
-.MT [email protected]
+.MT \%jdoe@\:example\:.com
 Write to me
 .ME \c
  with your questions.
@@ -145,27 +145,22 @@
 .
 .SS URIs with known schemes
 .sp
-.UR tel:+48-816-555-1212
-tel:+48\-816\-555\-1212
+.UR \%tel:+48-816-555-1212
 .UE
 .
-.UR urn:isbn:0-486-27557-4
-urn:isbn:0\-486\-27557\-4
+.UR \%urn:isbn:0-486-27557-4
 .UE
 .
-.UR news:comp.infosystems.www.servers.unix
-news:comp.infosystems.www.servers.unix
+.UR \%news:comp\:.infosystems\:.www\:.servers\:.unix
 .UE
 .
-.UR https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
-https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
+.UR \%https://\:john\:.doe@\:www\:.example\:.com:123/\:forum/\:questions/?\:tag=networking&\:order=newest#\:top
 .UE
 .
 .SS Standalone email addresses
 .sp
 like \c
-.MT [email protected]
[email protected]
+.MT \%someone@\:somewhere\:.com
 .ME
 .
 .\" End of generated man page.

Modified: trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.ps
===================================================================
--- trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.ps	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.ps	2025-04-25 16:21:29 UTC (rev 10109)
@@ -271,28 +271,17 @@
 126.995(known)c
 161.535(schemes)c
 f0
-87.274 164.373(tel:+48-816-555-1212)s
-187.275(<tel:+48-816-555-1212>)c
-299.684(urn:isbn:0-486-27557-4)c
-407.539(<urn:isbn:0-486-27557-4>)c
-87.274 148.984(news:comp.infosystems.www.servers.unix)s
-278.223(<news:comp.infosystems.www.servers.unix>)c
-87.274 133.595(https://[email protected]:123/forum/questions/?tag=networking&order=newest#top)s
-87.274 118.206(<https://[email protected]:123/forum/questions/?tag=networking&order=newest#top>)s
-f0
-68.024 739.233(\(\))s
-536.932(\(\))c
-536.932 36.245(\(\))s
-showpage
-%%Page: 3 3
+87.274 164.373(<tel:+48-816-555-1212>)s
+199.683(<urn:isbn:0-486-27557-4>)c
+319.946(<news:comp.infosystems.www.servers.unix>)c
+87.274 148.984(<https://[email protected]:123/forum/questions/?tag=networking&order=newest#top>)s
 f1
-76.274 702.988(Standalone)s
+76.274 118.206(Standalone)s
 131.593(email)c
 160.006(addresses)c
 f0
-87.274 687.599(like)s
-106.524([email protected])c
-230.296(<[email protected]>)c
+87.274 102.817(like)s
+106.524(<[email protected]>)c
 f0
 68.024 739.233(\(\))s
 536.932(\(\))c
@@ -299,5 +288,5 @@
 536.932 36.245(\(\))s
 showpage
 %%Trailer
-%%Pages: 3
+%%Pages: 2
 %%EOF

Modified: trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.utf8
===================================================================
--- trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.utf8	2025-04-25 15:57:30 UTC (rev 10108)
+++ trunk/sandbox/manpage-writer/expected-mandoc/refs-urue.utf8	2025-04-25 16:21:29 UTC (rev 10109)
@@ -79,13 +79,11 @@
        Write to me <[email protected]> with your questions.
 
    UURRIIss wwiitthh kknnoowwnn sscchheemmeess
-       tel:+48-816-555-1212 <tel:+48-816-555-1212> urn:isbn:0-486-27557-4
-       <urn:isbn:0-486-27557-4> news:comp.infosystems.www.servers.unix
+       <tel:+48-816-555-1212> <urn:isbn:0-486-27557-4>
        <news:comp.infosystems.www.servers.unix>
-       https://[email protected]:123/forum/questions/?tag=networking&order=newest#top
        <https://[email protected]:123/forum/questions/?tag=networking&order=newest#top>
 
    SSttaannddaalloonnee eemmaaiill aaddddrreesssseess
-       like [email protected] <[email protected]>
+       like <[email protected]>
 
                                                                             ()

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins