summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStuart Rackham <srackham@methods.co.nz>2010-08-15 09:12:51 +1200
committerStuart Rackham <srackham@methods.co.nz>2010-08-15 09:12:51 +1200
commitea4b03b5ee933dbc6a2c141642b991302a082e90 (patch)
treec536556979fcef1d8732f8a8412aba59ef7d83fd
parent5812078790e1703f39621b332b927cc56023c969 (diff)
downloadasciidoc-ea4b03b5ee933dbc6a2c141642b991302a082e90.tar.gz
- The global configuration files directory is not used if AsciiDoc
configuration files are installed in the same directory as the asciidoc executable. This change allows both a system wide copy and multiple local copies of AsciiDoc to coexist on the same host PC. - Build script: Don't spellcheck via symlinks.
-rw-r--r--CHANGELOG.txt5
-rwxr-xr-xa2x.py26
-rwxr-xr-xasciidoc.py24
-rw-r--r--doc/a2x.1.txt6
-rw-r--r--doc/asciidoc.dict8
-rw-r--r--doc/asciidoc.txt11
-rw-r--r--doc/main.aap3
-rw-r--r--doc/source-highlight-filter.txt4
-rw-r--r--examples/website/asciidoc-website.dict5
-rw-r--r--examples/website/main.aap2
10 files changed, 62 insertions, 32 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 3c7d295..c6cc706 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -6,6 +6,11 @@ AsciiDoc ChangeLog
Version 8.5.4 (2010-08-15)
--------------------------
.Additions and changes
+- The global configuration files directory is ignored by both
+ 'asciidoc' and 'a2x' if AsciiDoc configuration files are installed
+ in the same directory as the asciidoc executable. This change
+ allows both a system wide copy and multiple local copies of AsciiDoc
+ to coexist on the same host PC.
- CSS 'quirks' mode is no longer the default 'xhtml11' output
(http://groups.google.com/group/asciidoc/browse_thread/thread/1c02d27d49221aa2).
- Relaxed anchor ID name syntax
diff --git a/a2x.py b/a2x.py
index 07c4f21..c62791e 100755
--- a/a2x.py
+++ b/a2x.py
@@ -351,12 +351,20 @@ class A2X(AttrDict):
'''
global ASCIIDOC
CONF_FILE = 'a2x.conf'
+ a2xdir = os.path.dirname(os.path.realpath(__file__))
conf_files = []
- # From global conf directory.
- conf_files.append(os.path.join(CONF_DIR, CONF_FILE))
# From a2x.py directory.
- conf_files.append(os.path.join(
- os.path.dirname(os.path.realpath(__file__)), CONF_FILE))
+ conf_files.append(os.path.join(a2xdir, CONF_FILE))
+ # If the asciidoc executable and conf files are in the a2x directory
+ # then use the local copy of asciidoc and skip the global a2x conf.
+ asciidoc = os.path.join(a2xdir, 'asciidoc.py')
+ asciidoc_conf = os.path.join(a2xdir, 'asciidoc.conf')
+ if os.path.isfile(asciidoc) and os.path.isfile(asciidoc_conf):
+ self.asciidoc = asciidoc
+ else:
+ self.asciidoc = None
+ # From global conf directory.
+ conf_files.append(os.path.join(CONF_DIR, CONF_FILE))
# From $HOME directory.
home_dir = os.environ.get('HOME')
if home_dir is not None:
@@ -371,14 +379,10 @@ class A2X(AttrDict):
if os.path.isfile(f):
verbose('loading conf file: %s' % f)
execfile(f, globals())
- self.asciidoc = find_executable(ASCIIDOC)
- # If asciidoc can't be found anywhere else look in the a2x directory.
+ # If asciidoc is not local to a2x then search the PATH.
if not self.asciidoc:
- a2xdir = os.path.dirname(os.path.realpath(__file__))
- asciidoc = os.path.join(a2xdir, 'asciidoc.py')
- if os.path.isfile(asciidoc):
- self.asciidoc = asciidoc
- else:
+ self.asciidoc = find_executable(ASCIIDOC)
+ if not self.asciidoc:
die('unable to find asciidoc: %s' % ASCIIDOC)
def process_options(self):
diff --git a/asciidoc.py b/asciidoc.py
index 035d4d8..e16ede6 100755
--- a/asciidoc.py
+++ b/asciidoc.py
@@ -215,6 +215,13 @@ class Message:
self.error('unsafe: '+msg)
+def localapp():
+ """
+ Return True if we are not executing the system wide version
+ i.e. the configuration is in the executable's directory.
+ """
+ return os.path.isfile(os.path.join(APP_DIR, 'asciidoc.conf'))
+
def file_in(fname, directory):
"""Return True if file fname resides inside directory."""
assert os.path.isfile(fname)
@@ -651,9 +658,10 @@ def filter_lines(filter_cmd, lines, attrs={}):
if USER_DIR:
found = findfilter(filtername, USER_DIR, cmd)
if not found:
- found = findfilter(filtername, CONF_DIR, cmd)
- if not found:
- found = findfilter(filtername, APP_DIR, cmd)
+ if localapp():
+ found = findfilter(filtername, APP_DIR, cmd)
+ else:
+ found = findfilter(filtername, CONF_DIR, cmd)
else:
if os.path.isfile(cmd):
found = cmd
@@ -4280,10 +4288,12 @@ class Config:
def get_load_dirs(self):
"""Return list of well known paths to search for conf files."""
result = []
- # Load global configuration from system configuration directory.
- result.append(CONF_DIR)
- # Load global configuration files from folders in asciidoc directory.
- result.append(APP_DIR)
+ if localapp():
+ # Load from folders in asciidoc executable directory.
+ result.append(APP_DIR)
+ else:
+ # Load from global configuration directory.
+ result.append(CONF_DIR)
# Load configuration files from ~/.asciidoc if it exists.
if USER_DIR is not None:
result.append(USER_DIR)
diff --git a/doc/a2x.1.txt b/doc/a2x.1.txt
index a0f1199..8096677 100644
--- a/doc/a2x.1.txt
+++ b/doc/a2x.1.txt
@@ -203,10 +203,12 @@ A configuration file contains executable Python code that overrides
the global configuration parameters in `a2x.py`. Optional configuration
files are loaded in the following order:
-. `a2x.conf` from the AsciiDoc global configuration directory.
+. `a2x.conf` from the directory containing the 'a2x.py' executable.
+. `a2x.conf` from the AsciiDoc global configuration directory. Skip
+ this step if we are executing a locally installed (non system wide)
+ copy.
. `a2x.conf` from the AsciiDoc `$HOME/.asciidoc` configuration
directory.
-. `a2x.conf` from the directory containing 'a2x.py'.
. The 'CONF_FILE' specified in the '--conf-file' option.
Here are the default configuration file option values:
diff --git a/doc/asciidoc.dict b/doc/asciidoc.dict
index 482859e..17d0b9a 100644
--- a/doc/asciidoc.dict
+++ b/doc/asciidoc.dict
@@ -1,4 +1,4 @@
-personal_ws-1.1 en 972
+personal_ws-1.1 en 974
mandoc
colspecs
API
@@ -113,6 +113,7 @@ magna
xreflabel
PDF's
PDFs
+pygmentize
MSIE
pede
permalinks
@@ -246,7 +247,7 @@ CustomBlocks
refentryinfo
informalfigure
ORed
-Pygments
+pygments
yyyy
online
LIBDIR
@@ -400,6 +401,7 @@ xsl
backmatter
ar
fils
+linenumbering
de
backends
eb
@@ -963,7 +965,7 @@ topbot
greek
comspec
refmiscinfo
-Firefox
+firefox
lectus
JavaHelp
unescaped
diff --git a/doc/asciidoc.txt b/doc/asciidoc.txt
index 786991c..0efa0b9 100644
--- a/doc/asciidoc.txt
+++ b/doc/asciidoc.txt
@@ -3562,9 +3562,14 @@ option).
Implicit configuration files are loaded from the following directories
in the following order:
-1. The global configuration directory (normally `/etc/asciidoc` or
- `/usr/local/etc/asciidoc`) if it exists.
-2. The directory containing the asciidoc executable.
+1. The directory containing the asciidoc executable.
+2. If there is no `asciidoc.conf` file in the directory containing the
+ asciidoc executable then load from the global configuration
+ directory (normally `/etc/asciidoc` or `/usr/local/etc/asciidoc`)
+ i.e. the global configuration files directory is skipped if
+ AsciiDoc configuration files are installed in the same directory as
+ the asciidoc executable. This allows both a system wide copy and
+ multiple local copies of AsciiDoc to coexist on the same host PC.
3. The user's `$HOME/.asciidoc` directory (if it exists).
4. The directory containing the AsciiDoc source file.
diff --git a/doc/main.aap b/doc/main.aap
index cd313f1..5d42f57 100644
--- a/doc/main.aap
+++ b/doc/main.aap
@@ -217,7 +217,8 @@ clean:
spell: $INFILES ../CHANGELOG.txt ../README.txt ../BUGS.txt ../INSTALL.txt \
a2x.1.txt faq.txt asciidocapi.txt testasciidoc.txt \
- epub-notes.txt publishing-ebooks-with-asciidoc.txt
+ epub-notes.txt publishing-ebooks-with-asciidoc.txt \
+ source-highlight-filter.txt
# Interactively spell check all files.
@for s in source_list:
:sys {i} $ASPELL check -p ./asciidoc.dict $s
diff --git a/doc/source-highlight-filter.txt b/doc/source-highlight-filter.txt
index 992529c..35aad77 100644
--- a/doc/source-highlight-filter.txt
+++ b/doc/source-highlight-filter.txt
@@ -5,7 +5,7 @@ The AsciiDoc distribution includes a source code syntax highlight
filter (`source-highlight-filter.conf`). It uses
http://www.gnu.org/software/src-highlite/[GNU source-highlight] to
highlight HTML outputs. You also have the option of using the
-http://pygments.org/[Pygments] syntax highlighter for 'xhtm11'
+http://pygments.org/[Pygments] syntax highlighter for 'xhtml11'
outputs.
To use Pygments you need to define an AsciiDoc attribute named
@@ -25,7 +25,7 @@ DocBook outputs are highlighted by toolchains that have
'AttributeEntry' or from the command-line) you don't have to specify
it in each source code block.
- You may need to place callout markers inside source code comments to
- ensure they are not misinterpereted and mangled by the hightlighter.
+ ensure they are not misinterpreted and mangled by the highlighter.
=====
Examples
diff --git a/examples/website/asciidoc-website.dict b/examples/website/asciidoc-website.dict
index 6855fe5..8a2df5d 100644
--- a/examples/website/asciidoc-website.dict
+++ b/examples/website/asciidoc-website.dict
@@ -1,4 +1,4 @@
-personal_ws-1.1 en 201
+personal_ws-1.1 en 204
O'Reilly
awb
Blogpost
@@ -66,6 +66,8 @@ matplotlib
stdout
usr
txt
+ebooks
+eBooks
linenumbering
ImageMagick
distros
@@ -123,6 +125,7 @@ mkdir
Solaris
LilyPond
dx
+eBook
hg
Gouichi
conf
diff --git a/examples/website/main.aap b/examples/website/main.aap
index f53013a..8ba9e5e 100644
--- a/examples/website/main.aap
+++ b/examples/website/main.aap
@@ -53,8 +53,6 @@ SPELL_CHECK =
index.txt
README-website.txt
support.txt
- source-highlight-filter.txt
- music-filter.txt
# Accompanying documents in DOCS_DIR.
DOCS_ROOT =