Commits

Stuart Rackham  committed d2ef054

- The RCS $Id$ marker format is processed if the 'revision' attribute is
assigned in the document header.
- If an RCS $Id$ marker revision is specified and the author name has not
already been specified then the author name from the $Id$ marker will be
used.
- An RCS $Id$ marker in the header does not need to be preceded by an author
line.

  • Participants
  • Parent commits d75e155

Comments (0)

Files changed (2)

 
 class Header:
     """Static methods and attributes only."""
+    REV_LINE_RE = r'^(\D*(?P<revision>.*?),)?(?P<date>.+)$'
+    RCS_ID_RE = r'^\$Id: \S+ (?P<revision>\S+) (?P<date>\S+) \S+ (?P<author>\S+) (\S+ )?\$$'
     def __init__(self):
         raise AssertionError,'no class instances allowed'
     @staticmethod
                 attrs['manvolnum'] = mo.group('manvolnum').strip()
         AttributeEntry.translate_all()
         s = reader.read_next()
+        mo = None
         if s:
             s = reader.read()
-            document.parse_author(s)
+            mo = re.match(Header.RCS_ID_RE,s)
+            if not mo:
+                document.parse_author(s)
+                AttributeEntry.translate_all()
+                if reader.read_next():
+                    # Parse revision line.
+                    s = reader.read()
+                    s = subs_attrs(s)
+                    if s:
+                        mo = re.match(Header.RCS_ID_RE,s)
+                        if not mo:
+                            mo = re.match(Header.REV_LINE_RE,s)
             AttributeEntry.translate_all()
-            if reader.read_next():
-                # Parse revision line.
-                s = reader.read()
-                s = subs_attrs(s)
-                if s:
-                    # Match RCS/CVS/SVN $Id$ marker format.
-                    mo = re.match(r'^\$Id: \S+ (?P<revision>\S+)'
-                         ' (?P<date>\S+) \S+ \S+ (\S+ )?\$$',s)
-                    if not mo:
-                        # Match AsciiDoc revision,date format.
-                        mo = re.match(r'^\D*(?P<revision>.*?),(?P<date>.+)$',s)
-                    if mo:
-                        revision = mo.group('revision').strip()
-                        date = mo.group('date').strip()
-                    else:
-                        revision = None
-                        date = s.strip()
-                    if revision:
-                        attrs['revision'] = config.subs_specialchars(revision)
-                    if date:
-                        attrs['date'] = config.subs_specialchars(date)
-            AttributeEntry.translate_all()
+        if 'revision' in attrs:
+            s = attrs['revision']
+            if s:
+                mo = re.match(Header.RCS_ID_RE,s)
+        if mo:
+            revision = mo.group('revision')
+            date = mo.group('date')
+            author = mo.groupdict().get('author')
+            if revision:
+                attrs['revision'] = revision.strip()
+            if date:
+                attrs['date'] = date.strip()
+            if author and 'firstname' not in attrs:
+                document.parse_author(author)
         if document.doctype == 'manpage':
             # Translate mandatory NAME section.
             if Lex.next() is not Title:

File doc/asciidoc.txt

     numeric character.
   * Any non-numeric characters preceding the first numeric character
     will be dropped.
-. An RCS/CSV/SVN $Id$ marker.
+. An RCS/CSV/SVN $Id$ marker (if an $Id$ revision marker is used the
+  header author line can be omitted).
 
 The document heading is separated from the remainder of the document
 by one or more blank lines.
 
   $ asciidoc -a date=2004/07/27 article.txt
 
+The 'revision' attribute can be an RCS/CSV/SVN $Id$ marker.
 Attributes can also be added to the header for substitution in the
 header template with <<X18,Attribute Entry>> elements.