[latexrefman-commits] [SCM] latexrefman updated: r690 - in trunk: . src

jimhefferon at gnu.org.ua jimhefferon at gnu.org.ua
Sat Sep 15 17:20:20 CEST 2018


Author: jimhefferon
Date: 2018-09-15 18:20:19 +0300 (Sat, 15 Sep 2018)
New Revision: 690

Added:
   trunk/latexreflocal.css
Removed:
   trunk/latex2elocal.css
   trunk/src/_version.py
Modified:
   trunk/ChangeLog
   trunk/Makefile
   trunk/latex2e.css
   trunk/latex2e.dbk
   trunk/latex2e.dvi
   trunk/latex2e.html
   trunk/latex2e.info
   trunk/latex2e.pdf
   trunk/latex2e.texi
   trunk/latex2e.xml
   trunk/src/easyurls.py
   trunk/src/test_easyurls.sh
Log:
Several adjustments to easy urls script

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/ChangeLog	2018-09-15 15:20:19 UTC (rev 690)
@@ -1,3 +1,14 @@
+2018-09-15  Jim Hefferon  <jhefferon at smcvt.edu>
+
+	* easyurls.py  Added ability to inject text into top of index.html.
+	Added that it does not make pointers to files created by @anchor(..).
+	* latex2e.texi Restore Starting & ending anchor.
+	* latex2elocal.css  Changed name to latexreflocal.css
+	* latex.css  Add quotes on @import ...
+	* Makefile  Keep split files from having a footer.
+	* _version.py Incorporated contents into easyurls.py, to make it
+	self-contained.
+
 2018-09-08  Karl Berry  <karl at freefriends.org>
 
 	* Makefile (t2html_home): use https://latexref.xyz.

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/Makefile	2018-09-15 15:20:19 UTC (rev 690)
@@ -29,7 +29,7 @@
 texi2txt = $(makeinfo) --plaintext --no-split
 texi2xml = $(makeinfo) --xml
 #
-htmlopts = --html --css-include=latex2e.css $(t2html_top) $(t2html_home)
+htmlopts = --html --css-include=latex2e.css $(t2html_top) $(t2html_home) -c WORDS_IN_PAGE=10000
 #
 # Go somewhere useful from Top:
 t2html_top = -c TOP_NODE_UP_URL=http://tug.org/texinfohtml/

Modified: trunk/latex2e.css
===================================================================
--- trunk/latex2e.css	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.css	2018-09-15 15:20:19 UTC (rev 690)
@@ -3,7 +3,7 @@
    Originally written by Jim Hefferon and Karl Berry, 2018. */
 
 /* So you can style for yourself */
- at import url(latex2elocal.css);
+ at import url("/css/latexreflocal.css");
 
 
 BODY {

Modified: trunk/latex2e.dbk
===================================================================
--- trunk/latex2e.dbk	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.dbk	2018-09-15 15:20:19 UTC (rev 690)
@@ -233,7 +233,8 @@
 <sect1 label="2.1" id="Starting-and-ending">
 <title>Starting and ending</title>
 
-<!-- 2018-Sep-02 JH redundant on URL scheme @anchor{Starting & ending}@c old name -->
+<!-- 2018-Sep-02 JH redundant on URL scheme -->
+<anchor id="Starting-_0026-ending"/><!-- old name -->
 <indexterm role="cp"><primary>starting and ending</primary></indexterm>
 <indexterm role="cp"><primary>ending and starting</primary></indexterm>
 <indexterm role="cp"><primary>hello, world</primary></indexterm>

Modified: trunk/latex2e.dvi
===================================================================
(Binary files differ)

Modified: trunk/latex2e.html
===================================================================
--- trunk/latex2e.html	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.html	2018-09-15 15:20:19 UTC (rev 690)
@@ -52,12 +52,12 @@
 <link href="http://tug.org/texinfohtml/" rel="up" title="(dir)">
 <style type="text/css">
 <!--
-/* $Id: latex2e.css 683 2018-07-16 19:01:39Z karl $
+/* $Id: latex2e.css 687 2018-09-08 10:58:06Z jimhefferon $
    Minor css for latexrefman. Public domain.
    Originally written by Jim Hefferon and Karl Berry, 2018. */
 
 /* So you can style for yourself */
- at import url(latex2elocal.css);
+ at import url("/css/latexreflocal.css");
 
 
 
@@ -98,12 +98,6 @@
    and Texinfo won't fix it. */
 code {font-style:normal; font-family:monospace; }
 
-/* Make the navigation header less obtrusive. */
-/* .header {font-size:small; } */
-
-/* A little bit of color for fun. */
-/* h3 {color:#007849; }  */
-
 /* We put a link to our own home page at the bottom. */
 div.referenceinfo {font-size:small;}
 
@@ -761,7 +755,7 @@
 <a name="Starting-and-ending-1"></a>
 <h3 class="section">2.1 Starting and ending</h3>
 
-<a name="index-starting-and-ending"></a>
+<a name="Starting-_0026-ending"></a><a name="index-starting-and-ending"></a>
 <a name="index-ending-and-starting"></a>
 <a name="index-hello_002c-world"></a>
 

Modified: trunk/latex2e.info
===================================================================
--- trunk/latex2e.info	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.info	2018-09-15 15:20:19 UTC (rev 690)
@@ -17590,6 +17590,7 @@
 Node: About this document3652
 Node: Overview5504
 Node: Starting and ending7053
+Ref: Starting & ending7188
 Node: Output files8365
 Ref: output files dvi8644
 Ref: output files pdf9155

Modified: trunk/latex2e.pdf
===================================================================
(Binary files differ)

Modified: trunk/latex2e.texi
===================================================================
--- trunk/latex2e.texi	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.texi	2018-09-15 15:20:19 UTC (rev 690)
@@ -282,7 +282,7 @@
 @node Starting and ending
 @section Starting and ending
 
- at c 2018-Sep-02 JH redundant on URL scheme @anchor{Starting & ending}@c old name
+ at anchor{Starting & ending}@c old name
 @cindex starting and ending
 @cindex ending and starting
 @cindex hello, world

Modified: trunk/latex2e.xml
===================================================================
--- trunk/latex2e.xml	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/latex2e.xml	2018-09-15 15:20:19 UTC (rev 690)
@@ -3,7 +3,7 @@
 <texinfo xml:lang="en">
 <filename file="latex2e.xml"></filename>
 <preamble>\input texinfo
-</preamble><!-- c $Id: latex2e.texi 686 2018-08-09 12:28:40Z jimhefferon $ -->
+</preamble><!-- c $Id: latex2e.texi 687 2018-09-08 10:58:06Z jimhefferon $ -->
 <!-- comment %**start of header (This is for running Texinfo on a region.) -->
 <setfilename file="latex2e.info" spaces=" ">latex2e.info</setfilename>
 <set name="UPDATED" line=" UPDATED July 2018">July 2018</set>
@@ -281,7 +281,8 @@
 <node name="Starting-and-ending" spaces=" "><nodename>Starting and ending</nodename><nodenext automatic="on">Output files</nodenext><nodeup automatic="on">Overview</nodeup></node>
 <section spaces=" "><sectiontitle>Starting and ending</sectiontitle>
 
-<!-- c 2018-Sep-02 JH redundant on URL scheme @anchor{Starting & ending}@c old name -->
+<!-- c 2018-Sep-02 JH redundant on URL scheme -->
+<anchor name="Starting-_0026-ending">Starting & ending</anchor><!-- c old name -->
 <cindex index="cp" spaces=" "><indexterm index="cp" number="15">starting and ending</indexterm></cindex>
 <cindex index="cp" spaces=" "><indexterm index="cp" number="16">ending and starting</indexterm></cindex>
 <cindex index="cp" spaces=" "><indexterm index="cp" number="17">hello, world</indexterm></cindex>

Modified: trunk/src/easyurls.py
===================================================================
--- trunk/src/easyurls.py	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/src/easyurls.py	2018-09-15 15:20:19 UTC (rev 690)
@@ -3,11 +3,12 @@
 """
 Create easier urls for latexrefman tree view
 """
-from _version import __version__, __author__, __license__
+__version__ = '0.9.5'
+__author__ = 'Jim Hefferon'
+__license__ = 'GPL 3'
 
+# For TODO's, limitations, etc.
 __NOTES__="""
-1) Change web server's default file from index.html because of clash with 
-Index.html?
 """
 
 import sys
@@ -52,11 +53,11 @@
     log.warning(s)
 
 def error(s, level=10):
-    log.error(s)
+    log.error(s,exc_info=True)
     sys.exit(level)
 
 def critical(s, level=1):
-    log.critical(s)
+    log.critical(s,exc_info=True)
     sys.exit(level)
 
 
@@ -71,43 +72,119 @@
 if not(DEFAULT_ACTION in ACTION_CHOICES):
     critical("DEFAULT_ACTION "+str(DEFAULT_ACTION)+ \
              " must be in ACTION_CHOICES="+str(ACTION_CHOICES))
+
+
     
 # ===========================================================
-# def remove_all_anchor_files(root_dn):
-#     """Remove files left by TeXinfo to point to anchors
+INDEX_FILE_INTRO = """
+<div class='intro'>
+<p>This is a reference manual for LaTeX.
+If you want a tutorial then instead see
+<a href='https://ctan.org/topic/tut-latex'>this list</a>.
+</p>
+ 
+<p>
+Our goal is document all author-level commands.
+See below for the 
+<a href='#SEC_Overview'>Table of Contents</a>.
+Your comments and contributions, including bug reports, are very welcome.
+<a href='https://puszcza.gnu.org.ua/software/latexrefman/'>Our home page</a>
+has more information, including license information.
+</p>
 
-#     root_dn  string  Name of directory below which to look
-#     """
-#     for root, dirs, files in os.walk(root_dn, topdown = True):
-#         for fn in files:
-#             remove_if_anchor_file(os.path.join(root,fn))
+<p>
+This document is unofficial.
+It has not been reviewed by the LaTeX maintainers.
+</p>
+
+<p>
+<i>A note about links.</i>
+Some characters cannot apppear in a web link.
+One such character is backslash and so our
+page for the paragraph command <code>\par</code> 
+is named <code>_005cpar.html</code> (the representation of backslash 
+in hexadecimal is 005c).
+For these hard to remember links we have alternative page names, in this case
+<a href='bs-par.html'><code>bs-par.html</code></a>.
+These alternative names 
+replace space with a dash, `<code>-</code>', 
+replace backslash with `<code>bs</code>' and a dash,
+replace @ with `<code>at</code>' and a dash, 
+and replace & with `<code>and</code>' and a dash.
+For instance, you can reach the page describing
+<code>\@startsection</code> with 
+<a href='bs-at-startsection.html'><code>bs-at-startsection.html</code></a>.
+</p>
+</div>
+"""
+
+def rewrite_index_file(dn='', fn='index.html'):
+    """Massage the index file to contain an introduction"""
+    fullfn=os.path.join(dn,fn)
+    try:
+        with open(fullfn,'r') as f:
+            html = f.read()
+    except OSError as err:
+        error("Error reading index file {0}: {1!s}".format(fullfn, err),
+              level=70)
+    # Peel out the third section
+    top = html.split('<a name="Top"></a>', maxsplit=1)[0]
+    b="""<hr>
+<div class="header">
+<p>"""
+    bottom = html.split(b, maxsplit=1)[1]
+    html = top + b + bottom
+    # Insert intro
+    a = '<a name="SEC_Overview"></a>'
+    page_parts = html.split(a, maxsplit=1)
+    new_html = (INDEX_FILE_INTRO+a).join(page_parts)
+    try:
+        with open(fullfn,'w') as f:
+            html = f.write(new_html)
+    except OSError as err:
+        error("Error writing index file {0}: {1!s}".format(fullfn, err),
+              level=71)
+
+    
+# ===========================================================
+ANCHOR_PAGES_TO_NOT_REMOVE = set()
+def remove_all_anchor_files(root_dn):
+    """Remove HTML files left by the TeXinfo @anchor() command
+
+    root_dn  string  Name of directory below which to look
+    """
+    for root, dirs, files in os.walk(root_dn, topdown = True):
+        for fn in files:
+            if not(fn in ANCHOR_PAGES_TO_NOT_REMOVE):
+                remove_if_anchor_file(os.path.join(root,fn))
             
-# def remove_if_anchor_file(fn):
-#     if not(fn.endswith(".html")):
-#         return
-#     try:
-#         with open(fn,'r') as f:
-#             html = f.read()
-#     except OSError as err:
-#         error("Error reading file {0}: {1!s}".format(fn, err),
-#               level=20)
-#     if _is_anchor_file(html):
-#         if DEBUG:
-#             print("Removing anchor file {}".format(fn))
-#         try:  
-#             os.remove(fn)
-#         except OSError as err:  
-#             error("Failed to remove anchor file {0}: {1!s}".format(fn, err),
-#                   level=20)
+def remove_if_anchor_file(fn):
+    if _is_anchor_file(fn):
+        if DEBUG:
+            print("Removing anchor file {}".format(fn))
+        try:  
+            os.remove(fn)
+        except OSError as err:  
+            error("Failed to remove anchor file {0}: {1!s}".format(fn, err),
+                  level=20)
         
-# def _is_anchor_file(html):
-#     soup = BeautifulSoup(html, "html.parser")
-#     plist = soup.find_all("p")
-#     if ((len(plist) == 1)
-#         and plist[0].string.startswith("The node you are looking for is at")):
-#         return True
-#     else:
-#         return False
+def _is_anchor_file(fn):
+    if not(fn.endswith(".html")):
+        return
+    try:
+        with open(fn,'r') as f:
+            html = f.read()
+    except OSError as err:
+        error("Error reading file {0}: {1!s}".format(fn, err),
+              level=20)
+    soup = BeautifulSoup(html, "html.parser")
+    plist = soup.find_all("p")
+    # print("  fn="+fn+"  plist="+pprint.pformat(plist))
+    if ((len(plist) == 1)
+        and (hasattr(plist[0],'next_element'))
+        and (plist[0].next_element.startswith("The node you are looking for is at"))):
+        return True
+    return False
 
 # ===========================================================
 hex_substring = re.compile('_00[0-9,a-f]{2}')    
@@ -144,11 +221,11 @@
 # Rules TeXInfo uses are in texinfo_23.html#Generating-HTML
 # https://perishablepress.com/stop-using-unsafe-characters-in-urls/
 URL_SAFE_CHARS = set(string.digits+string.ascii_letters+"$-_.+!*'(),")
-DEFAULT_TRANSLATIONS = {'_005c':'cmd',       # \
+DEFAULT_TRANSLATIONS = {'_005c':'bs',        # \
                         '_007e':'twiddle',   # ~
                         '_002f':'slash',     # /
                         '_0026':'and',       # &
-                        '_0040':'atsign',    # @
+                        '_0040':'at',        # @
                         '_002e':'.',         # .
                         '_002a':'*',         # *
                         '_002d':'dash',      # -
@@ -181,6 +258,8 @@
         for fn in files:
             if fn in inverse_mp:
                 fullfn = os.path.join(root, inverse_mp[fn])
+                if os.path.isfile(fullfn):
+                    error('Trying to make an include file with the name of an existing file: '+fn, 60)
                 try:
                     with open(fullfn,'w') as f:
                         f.write(s.format(fn=fn))
@@ -208,6 +287,8 @@
     root_dn  string  Root directory under which softlinks will be created
     inverse_mp  dict  string -> string  map untranslated fn to translated fn
     """
+    log.info("++++")
+    log.info("inverse_mp is: "+pprint.pformat(inverse_mp))
     num_softlinks = 0
     r = ["softlinks made:"]  # for log
     for root, dirs, files in os.walk(root_dn, topdown = True):
@@ -216,11 +297,14 @@
                 src = fn
                 dest = os.path.join(root, inverse_mp[fn])
                 r.append("  dest="+dest+" --> src="+src)
+                if os.path.isfile(dest):
+                    error('Trying to make an soft link with the name of an existing file: '+dest, 61)
                 try:
                     os.symlink(src, dest)
                     num_softlinks += 1
+                    # print("  dest="+dest+" --> src="+src+"   cwd="+os.getcwd())
                 except OSError as err:  
-                    error("Failed to create file softlink {0}: {1!s}".format(dest, err),
+                    error("Failed to create softlink {0}-->{1}: {2!s}".format(dest, src, err),
                           level=13)
         for dn in dirs:
             if dn in mp:
@@ -275,6 +359,8 @@
                 replaced_html = replace_urls(html, inverse_mp)
                 if fn in inverse_mp:
                     dest = os.path.join(root, inverse_mp[fn])
+                    if os.path.isfile(dest):
+                        error('Trying to make a new file with the name of an existing file: '+dest, 62)
                 else:
                     dest = os.path.join(root, fn)
                 try:
@@ -439,6 +525,10 @@
     for root, dirs, files in os.walk(root_dirname, topdown = True):
         for fn in files:
             hex_strings_spotted |= get_hex_strings(fn) # union of sets
+            fullfn = os.path.join(root, fn)
+            if _is_anchor_file(fullfn):  # don't translate it
+                log.debug("  anchor file: "+fn)
+                continue
             translated_name = rename(fn, rename_style)
             if translated_name in url_map:
                 s = 'file name '+fn+" translates to "+translated_name \
@@ -446,9 +536,7 @@
                 error(s)
             if translated_name != fn:
                 url_map[translated_name] = fn
-            # fullfn = os.path.join(root_dirname, fn)
-            if DEBUG: 
-                print("  "+fn+" --> "+translated_name)
+            log.debug("  "+fn+" --> "+translated_name)
         for dn in dirs:
             hex_strings_spotted |= get_hex_strings(dn) # union of sets
             translated_name = rename(dn, rename_style)
@@ -457,9 +545,7 @@
                 +' which is the same as '+url_map[translated_name]
                 error(s)
             url_map[translated_name] = dn
-            # fulldn = os.path.join(root_dirname, dn)
-            if DEBUG:
-                print("  Directory: "+dn+" --> "+translated_name)
+            log.debug("  Directory: "+dn+" --> "+translated_name)
         return url_map, hex_strings_spotted
 
 
@@ -472,6 +558,8 @@
                                                rename_style=args.style)
     log_spotted_strings(hex_substrings_spotted)
     action(dirname, url_map, action=args.action)
+    if args.rewrite_index:
+        rewrite_index_file(dn=args.directory_name)
 
 # ===========================================================
 if __name__ == '__main__':
@@ -494,7 +582,11 @@
         parser.add_argument('-l', '--lower_case',
                             action='store_true',
                             default=False,
-                            help="Have easy urls use lower case")
+                            help="Have easy urls use lower case. Default: False")
+        parser.add_argument('-r', '--rewrite_index',
+                            action='store_true',
+                            default=False,
+                            help="Rewrite index.html to have an intro. Default: False")
         parser.add_argument('-s', '--style',
                             action='store',
                             type=str,
@@ -506,10 +598,10 @@
         parser.add_argument('-D', '--debug',
                             action='store_true',
                             default=DEBUG,
-                            help='Run debugging code')
+                            help='Run debugging code. Default: '+str(DEBUG))
         parser.add_argument('-V', '--verbose', action='store_true',
                             default=VERBOSE,
-                            help='Give verbose output')
+                            help='Give verbose output. Default: '+str(VERBOSE))
         args = parser.parse_args()
         if args.verbose:
             fh.setLevel(logging.DEBUG)

Modified: trunk/src/test_easyurls.sh
===================================================================
--- trunk/src/test_easyurls.sh	2018-09-08 23:31:34 UTC (rev 689)
+++ trunk/src/test_easyurls.sh	2018-09-15 15:20:19 UTC (rev 690)
@@ -1,6 +1,8 @@
 #!/bin/bash
+#  Make a new set of HTML split files for latexrefman.
+# 2018-Sept-15 Jim Hefferon Public Domain
 
-# Make the tree
+# Compile the TeXinfo file
 cd ..
 make htmlsplit
 cd src
@@ -11,9 +13,13 @@
 mkdir -p latex2e
 rm -Rf latex2e
 unzip -q test/latex2e-help-texinfo-tree
-# ./easyurls.py --directory latex2e --action softlink --lower_case --verbose
+./easyurls.py --directory latex2e --action softlink --lower_case --rewrite_index --debug
 # ./easyurls.py --directory latex2e --action includefile --lower_case --verbose
-./easyurls.py --directory latex2e --action replace --lower_case --debug
-cp ../latex2elocal.css latex2e/latex2elocal.css
+# ./easyurls.py --directory latex2e --action replace --lower_case --debug
+# Better to keep it in /css: cp ../latexreflocal.css latex2e/latexreflocal.css
 
-date  # to tell if files are fresh
+# Move the new dir to take the place of the old.  First move old out of the way
+mv -T ../latex2e-help-texinfo-tree/latex2e tmp
+mv -T latex2e ../latex2e-help-texinfo-tree/latex2e
+rm -Rf tmp
+# date  # to tell if files are fresh



More information about the latexrefman-commits mailing list