On Sun, Oct 17, 2010 at 1:12 PM, Stuart Rackham <[email protected]> wrote:
> Lex, you are correct the litdd attribute is not defined at the time the
> header is parsed. The reason for this is that the local asciidoc.conf (the
> one in the same directory as the source file) is not loaded until after the
> header is parsed (only the system wide asciidoc.conf and the one in the
> user's $HOME/.asciidoc directory is loaded prior to parsing the header). The
> reason for this is that the local asciidoc.conf file will often contain
> backend related inclusions (which is the case with GIT's asciidoc.conf) and
> the backend is not guaranteed to be known until the header is parsed.
>
> The only way round this that I can see it to load the attributes and along
> with specialcharacters and titles sections (but nothing else) from the local
> asciidoc.conf file prior to parsing the header.
> I've committed a patch the implements this change and which should fix the
> problem:
> http://code.google.com/p/asciidoc/source/detail?r=02c8e59ce1b67ba91c7c77d1ab59c3a4524def33
>
> Teck Choon Giam, could you please test the patch and report back.

Ok here we go ;)

That patch is for 8.6.3 in your master branch?  Anyway, I don't know
how to pull the diff from google code site and have to manually create
the patch myself accordingly (see attached patch).

With the patch applied and I am able to compile successfully using:

make -j8 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 \
-march=i386 -mtune=generic -fasynchronous-unwind-tables' \
ETC_GITCONFIG=/etc/gitconfig prefix=/usr mandir=/usr/share/man
htmldir=/usr/share/doc/git-1.7.3 libdir=/usr/lib \
all doc

and

make -j8 'CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 \
-march=i386 -mtune=generic -fasynchronous-unwind-tables' \
ETC_GITCONFIG=/etc/gitconfig prefix=/usr mandir=/usr/share/man
htmldir=/usr/share/doc/git-1.7.3 libdir=/usr/lib \
ASCIIDOC8=1 all doc

So thanks for all you guys involved (Michael, Lex and Stuart) ;)

Kindest regards,
Giam Teck Choon

-- 
You received this message because you are subscribed to the Google Groups 
"asciidoc" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/asciidoc?hl=en.

--- a/asciidoc.py	2010-10-17 14:01:35.000000000 +0800
+++ b/asciidoc.py	2010-10-17 14:11:07.000000000 +0800
@@ -4260,10 +4260,12 @@
         self.include1 = {}      # Holds include1::[] files for {include1:}.
         self.dumping = False    # True if asciidoc -c option specified.
 
-    def load_file(self,fname,dir=None):
+    def load_file(self, fname, dir=None, include=[]):
         """
         Loads sections dictionary with sections from file fname.
         Existing sections are overlaid.
+        The 'include' list contains the section names to be loaded,
+        if 'inlude' is not specified all sections are loaded.
         Return False if no file was found in any of the locations.
         """
         if dir:
@@ -4317,9 +4319,14 @@
             else:
                 sections[section] = contents
         rdr.close()
+        if include:
+            for s in set(sections) - set(include):
+                del sections[s]
         attrs = {}
         self.load_sections(sections,attrs)
-        self.loaded.append(os.path.realpath(fname))
+        if not include:
+            # If all sections are loaded mark this file as loaded.
+            self.loaded.append(os.path.realpath(fname))
         document.update_attributes(attrs) # So they are available immediately.
         return True
 
@@ -5314,13 +5321,17 @@
             if o == '-c': config.dumping = True
             if o == '-s': config.header_footer = False
             if o == '-v': config.verbose = True
-        # Check the infile exists.
-        if infile != '<stdin>' and not os.path.isfile(infile):
-            raise EAsciiDoc,'input file %s missing' % infile
-        document.infile = infile
         # Load asciidoc.conf files.
         if not config.load_from_dirs('asciidoc.conf'):
             raise EAsciiDoc,'configuration file asciidoc.conf missing'
+        # Check the infile exists.
+        if infile != '<stdin>':
+            if not os.path.isfile(infile):
+                raise EAsciiDoc,'input file %s missing' % infile
+            indir = os.path.dirname(infile)
+            config.load_file('asciidoc.conf', indir,
+                            ['attributes','titles','specialchars'])
+        document.infile = infile
         AttributeList.initialize()
         # Open input file and parse document header.
         reader.tabsize = config.tabsize
@@ -5343,10 +5354,9 @@
             document.load_lang()
         # Load local conf files (conf files in the input file directory).
         if infile != '<stdin>':
-            d =os.path.dirname(infile)
-            config.load_from_dirs('asciidoc.conf', [d])
-            config.load_backend([d])
-            config.load_filters([d])
+            config.load_file('asciidoc.conf', indir)
+            config.load_backend([indir])
+            config.load_filters([indir])
             # Load document specific configuration files.
             f = os.path.splitext(infile)[0]
             config.load_file(f + '.conf')
--- a/doc/asciidoc.txt	2010-10-17 14:11:34.000000000 +0800
+++ b/doc/asciidoc.txt	2010-10-17 14:13:21.000000000 +0800
@@ -3632,6 +3632,8 @@
 the following order:
 
 - `asciidoc.conf` from locations 1, 2, 3.
+- 'attributes', 'titles' and 'specialcharacters' sections from the
+  `asciidoc.conf` in location 4.
 - The document header is parsed at this point.
 - `<backend>.conf` and `<backend>-<doctype>.conf` from locations 1,
   2,3.

Reply via email to