summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2020-06-05 00:04:45 -0400
committerMatthew Peveler <matt.peveler@gmail.com>2021-01-28 02:32:10 +0000
commit4d61d4bfa3ca00b01b543a13e695ed518b90ca6d (patch)
tree174d825629083b59ffa9ea3eaa36710f84079417
parent542e85f307f1fcfc21e48ee214052765b2f70440 (diff)
downloadasciidoc-py3-4d61d4bfa3ca00b01b543a13e695ed518b90ca6d.tar.gz
move asciidoc into proper python module structure
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
-rw-r--r--MANIFEST.in37
-rw-r--r--asciidoc/__init__.py1
-rw-r--r--asciidoc/__main__.py3
-rw-r--r--asciidoc/__metadata__.py5
-rw-r--r--[-rwxr-xr-x]asciidoc/a2x.py (renamed from a2x.py)24
-rw-r--r--[-rwxr-xr-x]asciidoc/asciidoc.py (renamed from asciidoc.py)100
-rw-r--r--asciidoc/resources/asciidoc.conf (renamed from asciidoc.conf)0
-rw-r--r--asciidoc/resources/docbook45.conf (renamed from docbook45.conf)0
-rw-r--r--asciidoc/resources/docbook5.conf (renamed from docbook5.conf)0
-rw-r--r--asciidoc/resources/filters/code/code-filter-readme.txt (renamed from filters/code/code-filter-readme.txt)0
-rw-r--r--asciidoc/resources/filters/code/code-filter-test.txt (renamed from filters/code/code-filter-test.txt)0
-rw-r--r--asciidoc/resources/filters/code/code-filter.conf (renamed from filters/code/code-filter.conf)0
-rwxr-xr-xasciidoc/resources/filters/code/code-filter.py (renamed from filters/code/code-filter.py)0
-rw-r--r--asciidoc/resources/filters/graphviz/asciidoc-graphviz-sample.txt (renamed from filters/graphviz/asciidoc-graphviz-sample.txt)0
-rw-r--r--asciidoc/resources/filters/graphviz/graphviz-filter.conf (renamed from filters/graphviz/graphviz-filter.conf)0
-rwxr-xr-xasciidoc/resources/filters/graphviz/graphviz2png.py (renamed from filters/graphviz/graphviz2png.py)0
-rw-r--r--asciidoc/resources/filters/latex/latex-filter.conf (renamed from filters/latex/latex-filter.conf)0
-rwxr-xr-xasciidoc/resources/filters/latex/latex2img.py (renamed from filters/latex/latex2img.py)0
-rw-r--r--asciidoc/resources/filters/music/music-filter-test.txt (renamed from filters/music/music-filter-test.txt)0
-rw-r--r--asciidoc/resources/filters/music/music-filter.conf (renamed from filters/music/music-filter.conf)0
-rwxr-xr-xasciidoc/resources/filters/music/music2png.py (renamed from filters/music/music2png.py)0
-rw-r--r--asciidoc/resources/filters/source/source-highlight-filter-test.txt (renamed from filters/source/source-highlight-filter-test.txt)0
-rw-r--r--asciidoc/resources/filters/source/source-highlight-filter.conf (renamed from filters/source/source-highlight-filter.conf)0
-rwxr-xr-xasciidoc/resources/filters/unwraplatex.py (renamed from filters/unwraplatex.py)0
-rw-r--r--asciidoc/resources/help.conf (renamed from help.conf)0
-rw-r--r--asciidoc/resources/html4.conf (renamed from html4.conf)0
-rw-r--r--asciidoc/resources/html5.conf (renamed from html5.conf)0
-rw-r--r--asciidoc/resources/icons/README (renamed from images/icons/README)0
-rw-r--r--asciidoc/resources/icons/callouts/1.png (renamed from images/icons/callouts/1.png)bin329 -> 329 bytes
-rw-r--r--asciidoc/resources/icons/callouts/10.png (renamed from images/icons/callouts/10.png)bin361 -> 361 bytes
-rw-r--r--asciidoc/resources/icons/callouts/11.png (renamed from images/icons/callouts/11.png)bin565 -> 565 bytes
-rw-r--r--asciidoc/resources/icons/callouts/12.png (renamed from images/icons/callouts/12.png)bin617 -> 617 bytes
-rw-r--r--asciidoc/resources/icons/callouts/13.png (renamed from images/icons/callouts/13.png)bin623 -> 623 bytes
-rw-r--r--asciidoc/resources/icons/callouts/14.png (renamed from images/icons/callouts/14.png)bin411 -> 411 bytes
-rw-r--r--asciidoc/resources/icons/callouts/15.png (renamed from images/icons/callouts/15.png)bin640 -> 640 bytes
-rw-r--r--asciidoc/resources/icons/callouts/2.png (renamed from images/icons/callouts/2.png)bin353 -> 353 bytes
-rw-r--r--asciidoc/resources/icons/callouts/3.png (renamed from images/icons/callouts/3.png)bin350 -> 350 bytes
-rw-r--r--asciidoc/resources/icons/callouts/4.png (renamed from images/icons/callouts/4.png)bin345 -> 345 bytes
-rw-r--r--asciidoc/resources/icons/callouts/5.png (renamed from images/icons/callouts/5.png)bin348 -> 348 bytes
-rw-r--r--asciidoc/resources/icons/callouts/6.png (renamed from images/icons/callouts/6.png)bin355 -> 355 bytes
-rw-r--r--asciidoc/resources/icons/callouts/7.png (renamed from images/icons/callouts/7.png)bin344 -> 344 bytes
-rw-r--r--asciidoc/resources/icons/callouts/8.png (renamed from images/icons/callouts/8.png)bin357 -> 357 bytes
-rw-r--r--asciidoc/resources/icons/callouts/9.png (renamed from images/icons/callouts/9.png)bin357 -> 357 bytes
-rw-r--r--asciidoc/resources/icons/caution.png (renamed from images/icons/caution.png)bin2734 -> 2734 bytes
-rw-r--r--asciidoc/resources/icons/example.png (renamed from images/icons/example.png)bin2599 -> 2599 bytes
-rw-r--r--asciidoc/resources/icons/home.png (renamed from images/icons/home.png)bin1340 -> 1340 bytes
-rw-r--r--asciidoc/resources/icons/important.png (renamed from images/icons/important.png)bin2980 -> 2980 bytes
-rw-r--r--asciidoc/resources/icons/next.png (renamed from images/icons/next.png)bin1302 -> 1302 bytes
-rw-r--r--asciidoc/resources/icons/note.png (renamed from images/icons/note.png)bin2494 -> 2494 bytes
-rw-r--r--asciidoc/resources/icons/prev.png (renamed from images/icons/prev.png)bin1348 -> 1348 bytes
-rw-r--r--asciidoc/resources/icons/tip.png (renamed from images/icons/tip.png)bin2718 -> 2718 bytes
-rw-r--r--asciidoc/resources/icons/up.png (renamed from images/icons/up.png)bin1320 -> 1320 bytes
-rw-r--r--asciidoc/resources/icons/warning.png (renamed from images/icons/warning.png)bin3214 -> 3214 bytes
-rw-r--r--asciidoc/resources/javascripts/ASCIIMathML.js (renamed from javascripts/ASCIIMathML.js)0
-rw-r--r--asciidoc/resources/javascripts/LaTeXMathML.js (renamed from javascripts/LaTeXMathML.js)0
-rw-r--r--asciidoc/resources/javascripts/asciidoc.js (renamed from javascripts/asciidoc.js)0
-rw-r--r--asciidoc/resources/javascripts/slidy.js (renamed from javascripts/slidy.js)0
-rw-r--r--asciidoc/resources/javascripts/toc.js (renamed from javascripts/toc.js)0
-rw-r--r--asciidoc/resources/lang-ca.conf (renamed from lang-ca.conf)0
-rw-r--r--asciidoc/resources/lang-cs.conf (renamed from lang-cs.conf)0
-rw-r--r--asciidoc/resources/lang-de.conf (renamed from lang-de.conf)0
-rw-r--r--asciidoc/resources/lang-el.conf (renamed from lang-el.conf)0
-rw-r--r--asciidoc/resources/lang-en.conf (renamed from lang-en.conf)0
-rw-r--r--asciidoc/resources/lang-es.conf (renamed from lang-es.conf)0
-rw-r--r--asciidoc/resources/lang-fi.conf (renamed from lang-fi.conf)0
-rw-r--r--asciidoc/resources/lang-fr.conf (renamed from lang-fr.conf)0
-rw-r--r--asciidoc/resources/lang-hu.conf (renamed from lang-hu.conf)0
-rw-r--r--asciidoc/resources/lang-id.conf (renamed from lang-id.conf)0
-rw-r--r--asciidoc/resources/lang-it.conf (renamed from lang-it.conf)0
-rw-r--r--asciidoc/resources/lang-ja.conf (renamed from lang-ja.conf)0
-rw-r--r--asciidoc/resources/lang-nl.conf (renamed from lang-nl.conf)0
-rw-r--r--asciidoc/resources/lang-pl.conf (renamed from lang-pl.conf)0
-rw-r--r--asciidoc/resources/lang-pt-BR.conf (renamed from lang-pt-BR.conf)0
-rw-r--r--asciidoc/resources/lang-ro.conf (renamed from lang-ro.conf)0
-rw-r--r--asciidoc/resources/lang-ru.conf (renamed from lang-ru.conf)0
-rw-r--r--asciidoc/resources/lang-sv.conf (renamed from lang-sv.conf)0
-rw-r--r--asciidoc/resources/lang-uk.conf (renamed from lang-uk.conf)0
-rw-r--r--asciidoc/resources/lang-zh-CN.conf (renamed from lang-zh-CN.conf)0
-rw-r--r--asciidoc/resources/latex.conf (renamed from latex.conf)0
-rw-r--r--asciidoc/resources/slidy.conf (renamed from slidy.conf)0
-rw-r--r--asciidoc/resources/stylesheets/asciidoc.css (renamed from stylesheets/asciidoc.css)0
-rw-r--r--asciidoc/resources/stylesheets/docbook-xsl.css (renamed from stylesheets/docbook-xsl.css)0
-rw-r--r--asciidoc/resources/stylesheets/pygments.css (renamed from stylesheets/pygments.css)0
-rw-r--r--asciidoc/resources/stylesheets/slidy.css (renamed from stylesheets/slidy.css)0
-rw-r--r--asciidoc/resources/stylesheets/toc2.css (renamed from stylesheets/toc2.css)0
-rw-r--r--asciidoc/resources/stylesheets/xhtml11-quirks.css (renamed from stylesheets/xhtml11-quirks.css)0
-rw-r--r--asciidoc/resources/text.conf (renamed from text.conf)0
-rw-r--r--asciidoc/resources/themes/flask/flask.css (renamed from themes/flask/flask.css)0
-rw-r--r--asciidoc/resources/themes/volnitsky/volnitsky.css (renamed from themes/volnitsky/volnitsky.css)0
-rw-r--r--asciidoc/resources/xhtml11-quirks.conf (renamed from xhtml11-quirks.conf)0
-rw-r--r--asciidoc/resources/xhtml11.conf (renamed from xhtml11.conf)0
-rw-r--r--asciidocapi.py308
-rw-r--r--build_manifest.sh9
-rw-r--r--setup.py117
-rw-r--r--tests/testasciidoc.conf2
-rwxr-xr-xtests/testasciidoc.py22
96 files changed, 248 insertions, 380 deletions
diff --git a/MANIFEST.in b/MANIFEST.in
index cce3b08..0c54b30 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,36 +1 @@
-dblatex/*
-doc/asciidoc.conf
-doc/article-docinfo.xml
-doc/customers.csv
-doc/*.txt
-doc/*.1
-doc/asciidoc.dict
-docbook-xsl/*
-filters/**/*
-filters/*.py
-images/*.png
-images/icons/callouts/*
-images/icons/*.png
-images/icons/README
-javascripts/*.js
-stylesheets/*.css
-tests/data/*
-tests/testasciidoc.py
-tests/testasciidoc.conf
-themes/**/*
-website/*
-*.conf
-*.sh
-*.py
-BUGS.txt
-CHANGELOG.txt
-configure
-configure.ac
-COPYRIGHT
-Dockerfile
-MANIFEST.in
-install-sh
-INSTALL.txt
-Makefile
-Makefile.in
-README.asciidoc
+recursive-include asciidoc/resources *.conf *.txt *.py *.png *.js *.css
diff --git a/asciidoc/__init__.py b/asciidoc/__init__.py
new file mode 100644
index 0000000..4086345
--- /dev/null
+++ b/asciidoc/__init__.py
@@ -0,0 +1 @@
+"""asciidoc module"""
diff --git a/asciidoc/__main__.py b/asciidoc/__main__.py
new file mode 100644
index 0000000..390092e
--- /dev/null
+++ b/asciidoc/__main__.py
@@ -0,0 +1,3 @@
+from asciidoc import cli
+
+cli()
diff --git a/asciidoc/__metadata__.py b/asciidoc/__metadata__.py
new file mode 100644
index 0000000..27fef80
--- /dev/null
+++ b/asciidoc/__metadata__.py
@@ -0,0 +1,5 @@
+"""Module containing metadata about asciidoc."""
+
+VERSION = (9, 0, 0)
+
+__version__ = '.'.join(map(str, VERSION))
diff --git a/a2x.py b/asciidoc/a2x.py
index 4715b48..8c58af3 100755..100644
--- a/a2x.py
+++ b/asciidoc/a2x.py
@@ -41,12 +41,13 @@ import zipfile
import xml.dom.minidom
import mimetypes
-PROG = os.path.basename(os.path.splitext(__file__)[0])
-VERSION = '9.0.5'
+CONF_DIR = os.path.join(os.path.dirname(__file__), 'resources')
+METADATA = {}
+with open(os.path.join(os.path.dirname(__file__), '__metadata__.py')) as f:
+ exec(f.read(), METADATA)
+VERSION = METADATA['__version__']
-# AsciiDoc global configuration file directory.
-# NOTE: CONF_DIR is "fixed up" by Makefile -- don't rename or change syntax.
-CONF_DIR = '/usr/local/etc/asciidoc'
+PROG = os.path.basename(os.path.splitext(__file__)[0])
######################################################################
@@ -886,11 +887,7 @@ class A2X(AttrDict):
shell_rm(html_file)
-#####################################################################
-# Script main line.
-#####################################################################
-
-if __name__ == '__main__':
+def cli():
description = '''A toolchain manager for AsciiDoc (converts Asciidoc text files to other file formats)'''
from optparse import OptionParser
parser = OptionParser(usage='usage: %prog [OPTIONS] SOURCE_FILE',
@@ -1013,3 +1010,10 @@ if __name__ == '__main__':
a2x.execute()
except KeyboardInterrupt:
sys.exit(1)
+
+#####################################################################
+# Script main line.
+#####################################################################
+
+if __name__ == "__main__":
+ cli()
diff --git a/asciidoc.py b/asciidoc/asciidoc.py
index c0f4d71..457269b 100755..100644
--- a/asciidoc.py
+++ b/asciidoc/asciidoc.py
@@ -32,8 +32,12 @@ import zipfile
from ast import literal_eval
from collections import OrderedDict
-# Used by asciidocapi.py #
-VERSION = '9.0.5' # See CHANGELOG file for version history.
+CONF_DIR = os.path.join(os.path.dirname(__file__), 'resources')
+METADATA = {}
+with open(os.path.join(os.path.dirname(__file__), '__metadata__.py')) as f:
+ exec(f.read(), METADATA)
+# See CHANGELOG file for version history.
+VERSION = METADATA['__version__']
MIN_PYTHON_VERSION = (3, 5) # Require this version of Python or better.
@@ -45,8 +49,8 @@ DEFAULT_DOCTYPE = 'article'
# Allowed substitution options for List, Paragraph and DelimitedBlock
# definition subs entry.
SUBS_OPTIONS = ('specialcharacters', 'quotes', 'specialwords',
- 'replacements', 'attributes', 'macros', 'callouts', 'normal', 'verbatim',
- 'none', 'replacements2', 'replacements3')
+ 'replacements', 'attributes', 'macros', 'callouts', 'normal',
+ 'verbatim', 'none', 'replacements2', 'replacements3')
# Default value for unspecified subs and presubs configuration file entries.
SUBS_NORMAL = ('specialcharacters', 'quotes', 'attributes',
'specialwords', 'replacements', 'macros', 'replacements2')
@@ -1272,6 +1276,11 @@ class Lex:
return self
@staticmethod
+ def reset_class():
+ Lex.prev_element = None
+ Lex.prev_cursor = None
+
+ @staticmethod
def next_element():
"""Returns class of next element on the input (None if EOF). The
reader is assumed to be at the first line following a previous element,
@@ -1827,6 +1836,15 @@ class AttributeEntry:
raise AssertionError('no class instances allowed')
@staticmethod
+ def reset_class():
+ AttributeEntry.pattern = None
+ AttributeEntry.subs = None
+ AttributeEntry.name = None
+ AttributeEntry.name2 = None
+ AttributeEntry.value = None
+ AttributeEntry.attributes = {}
+
+ @staticmethod
def isnext():
result = False # Assume not next.
if not AttributeEntry.pattern:
@@ -1914,6 +1932,12 @@ class AttributeList:
raise AssertionError('no class instances allowed')
@staticmethod
+ def reset_class():
+ AttributeList.pattern = None
+ AttributeList.match = None
+ AttributeList.attrs = {}
+
+ @staticmethod
def initialize():
if 'attributelist-pattern' not in document.attributes:
message.error("[attributes] missing 'attributelist-pattern' entry")
@@ -1981,6 +2005,11 @@ class BlockTitle:
raise AssertionError('no class instances allowed')
@staticmethod
+ def reset_class():
+ BlockTitle.title = None
+ BlockTitle.pattern = None
+
+ @staticmethod
def isnext():
result = False # Assume not next.
line = reader.read_next()
@@ -2030,6 +2059,17 @@ class Title:
raise AssertionError('no class instances allowed')
@staticmethod
+ def reset_class():
+ Title.subs = ()
+ Title.pattern = None
+ Title.level = 0
+ Title.attributes = {}
+ Title.sectname = None
+ Title.section_numbers = [0] * len(Title.underlines)
+ Title.dump_dict = {}
+ Title.linecount = None
+
+ @staticmethod
def translate(skipsubs=False):
"""Parse the Title.attributes and Title.level from the reader. The
real work has already been done by parse()."""
@@ -2250,6 +2290,11 @@ class Section:
raise AssertionError('no class instances allowed')
@staticmethod
+ def reset_class():
+ Section.endtags = []
+ Section.ids = []
+
+ @staticmethod
def savetag(level, etag):
"""Save section end."""
Section.endtags.append((level, etag))
@@ -2364,7 +2409,6 @@ class Section:
class AbstractBlock:
-
blocknames = [] # Global stack of names for push_blockname() and pop_blockname().
def __init__(self):
@@ -2396,6 +2440,10 @@ class AbstractBlock:
# Leading delimiter match object.
self.mo = None
+ @staticmethod
+ def reset_class():
+ AbstractBlock.blocknames = []
+
def short_name(self):
""" Return the text following the first dash in the section name."""
i = self.defname.find('-')
@@ -5945,6 +5993,10 @@ class Plugin:
type = None # 'backend', 'filter' or 'theme'.
@staticmethod
+ def reset_class():
+ Plugin.type = None
+
+ @staticmethod
def get_dir():
"""
Return plugins path (.asciidoc/filters or .asciidoc/themes) in user's
@@ -6059,8 +6111,6 @@ class Plugin:
APP_FILE = None # This file's full path.
APP_DIR = None # This file's directory.
USER_DIR = None # ~/.asciidoc
-# Global configuration files directory (set by Makefile build target).
-CONF_DIR = '/usr/local/etc/asciidoc'
HELP_FILE = 'help.conf' # Default (English) help file.
# Globals
@@ -6084,6 +6134,34 @@ trace = Trace() # Implements trace attribute processing.
messages = message.messages
+def reset_asciidoc():
+ global document, config, reader, writer, message
+ global paragraphs, lists, blocks, tables_OLD, tables
+ global macros, calloutmap, trace
+
+ document = Document()
+ config = Config()
+ reader = Reader()
+ writer = Writer()
+ message = Message()
+ paragraphs = Paragraphs()
+ lists = Lists()
+ blocks = DelimitedBlocks()
+ tables_OLD = Tables_OLD()
+ tables = Tables()
+ macros = Macros()
+ calloutmap = CalloutMap()
+ trace = Trace()
+
+ Lex.reset_class()
+ AttributeEntry.reset_class()
+ Title.reset_class()
+ BlockTitle.reset_class()
+ Section.reset_class()
+ AbstractBlock.reset_class()
+ Plugin.reset_class()
+
+
def asciidoc(backend, doctype, confiles, infile, outfile, options):
"""Convert AsciiDoc document to DocBook document of type doctype
The AsciiDoc document is read from file object src the translated
@@ -6200,7 +6278,7 @@ def asciidoc(backend, doctype, confiles, infile, outfile, options):
document.update_attributes()
# Set the default embedded icons directory.
if 'data-uri' in document.attributes and not os.path.isdir(document.attributes['iconsdir']):
- document.attributes['iconsdir'] = os.path.join(document.attributes['asciidoc-confdir'], 'images/icons')
+ document.attributes['iconsdir'] = os.path.join(document.attributes['asciidoc-confdir'], 'icons')
# Configuration is fully loaded.
config.expand_all_templates()
# Check configuration for consistency.
@@ -6409,7 +6487,7 @@ def execute(cmd, opts, args):
sys.stdin, sys.stdout = stdin, stdout
-if __name__ == '__main__':
+def cli():
# Process command line options.
try:
# DEPRECATED: --unsafe option.
@@ -6461,3 +6539,7 @@ if __name__ == '__main__':
execute(sys.argv[0], opts, args)
except KeyboardInterrupt:
sys.exit(1)
+
+
+if __name__ == "__main__":
+ cli()
diff --git a/asciidoc.conf b/asciidoc/resources/asciidoc.conf
index d1ca3fd..d1ca3fd 100644
--- a/asciidoc.conf
+++ b/asciidoc/resources/asciidoc.conf
diff --git a/docbook45.conf b/asciidoc/resources/docbook45.conf
index 51a579d..51a579d 100644
--- a/docbook45.conf
+++ b/asciidoc/resources/docbook45.conf
diff --git a/docbook5.conf b/asciidoc/resources/docbook5.conf
index bdf2ec9..bdf2ec9 100644
--- a/docbook5.conf
+++ b/asciidoc/resources/docbook5.conf
diff --git a/filters/code/code-filter-readme.txt b/asciidoc/resources/filters/code/code-filter-readme.txt
index 2a35f86..2a35f86 100644
--- a/filters/code/code-filter-readme.txt
+++ b/asciidoc/resources/filters/code/code-filter-readme.txt
diff --git a/filters/code/code-filter-test.txt b/asciidoc/resources/filters/code/code-filter-test.txt
index c9e8192..c9e8192 100644
--- a/filters/code/code-filter-test.txt
+++ b/asciidoc/resources/filters/code/code-filter-test.txt
diff --git a/filters/code/code-filter.conf b/asciidoc/resources/filters/code/code-filter.conf
index 5cdab96..5cdab96 100644
--- a/filters/code/code-filter.conf
+++ b/asciidoc/resources/filters/code/code-filter.conf
diff --git a/filters/code/code-filter.py b/asciidoc/resources/filters/code/code-filter.py
index 6a39dfb..6a39dfb 100755
--- a/filters/code/code-filter.py
+++ b/asciidoc/resources/filters/code/code-filter.py
diff --git a/filters/graphviz/asciidoc-graphviz-sample.txt b/asciidoc/resources/filters/graphviz/asciidoc-graphviz-sample.txt
index 4be6ba9..4be6ba9 100644
--- a/filters/graphviz/asciidoc-graphviz-sample.txt
+++ b/asciidoc/resources/filters/graphviz/asciidoc-graphviz-sample.txt
diff --git a/filters/graphviz/graphviz-filter.conf b/asciidoc/resources/filters/graphviz/graphviz-filter.conf
index f1ca264..f1ca264 100644
--- a/filters/graphviz/graphviz-filter.conf
+++ b/asciidoc/resources/filters/graphviz/graphviz-filter.conf
diff --git a/filters/graphviz/graphviz2png.py b/asciidoc/resources/filters/graphviz/graphviz2png.py
index a13c67d..a13c67d 100755
--- a/filters/graphviz/graphviz2png.py
+++ b/asciidoc/resources/filters/graphviz/graphviz2png.py
diff --git a/filters/latex/latex-filter.conf b/asciidoc/resources/filters/latex/latex-filter.conf
index e9b749f..e9b749f 100644
--- a/filters/latex/latex-filter.conf
+++ b/asciidoc/resources/filters/latex/latex-filter.conf
diff --git a/filters/latex/latex2img.py b/asciidoc/resources/filters/latex/latex2img.py
index 824fc8c..824fc8c 100755
--- a/filters/latex/latex2img.py
+++ b/asciidoc/resources/filters/latex/latex2img.py
diff --git a/filters/music/music-filter-test.txt b/asciidoc/resources/filters/music/music-filter-test.txt
index c1886bd..c1886bd 100644
--- a/filters/music/music-filter-test.txt
+++ b/asciidoc/resources/filters/music/music-filter-test.txt
diff --git a/filters/music/music-filter.conf b/asciidoc/resources/filters/music/music-filter.conf
index eaafe97..eaafe97 100644
--- a/filters/music/music-filter.conf
+++ b/asciidoc/resources/filters/music/music-filter.conf
diff --git a/filters/music/music2png.py b/asciidoc/resources/filters/music/music2png.py
index c758b4c..c758b4c 100755
--- a/filters/music/music2png.py
+++ b/asciidoc/resources/filters/music/music2png.py
diff --git a/filters/source/source-highlight-filter-test.txt b/asciidoc/resources/filters/source/source-highlight-filter-test.txt
index cd2390c..cd2390c 100644
--- a/filters/source/source-highlight-filter-test.txt
+++ b/asciidoc/resources/filters/source/source-highlight-filter-test.txt
diff --git a/filters/source/source-highlight-filter.conf b/asciidoc/resources/filters/source/source-highlight-filter.conf
index e945511..e945511 100644
--- a/filters/source/source-highlight-filter.conf
+++ b/asciidoc/resources/filters/source/source-highlight-filter.conf
diff --git a/filters/unwraplatex.py b/asciidoc/resources/filters/unwraplatex.py
index 05a7581..05a7581 100755
--- a/filters/unwraplatex.py
+++ b/asciidoc/resources/filters/unwraplatex.py
diff --git a/help.conf b/asciidoc/resources/help.conf
index a4b8775..a4b8775 100644
--- a/help.conf
+++ b/asciidoc/resources/help.conf
diff --git a/html4.conf b/asciidoc/resources/html4.conf
index 66d1f48..66d1f48 100644
--- a/html4.conf
+++ b/asciidoc/resources/html4.conf
diff --git a/html5.conf b/asciidoc/resources/html5.conf
index d21c6ec..d21c6ec 100644
--- a/html5.conf
+++ b/asciidoc/resources/html5.conf
diff --git a/images/icons/README b/asciidoc/resources/icons/README
index f12b2a7..f12b2a7 100644
--- a/images/icons/README
+++ b/asciidoc/resources/icons/README
diff --git a/images/icons/callouts/1.png b/asciidoc/resources/icons/callouts/1.png
index 7d47343..7d47343 100644
--- a/images/icons/callouts/1.png
+++ b/asciidoc/resources/icons/callouts/1.png
Binary files differ
diff --git a/images/icons/callouts/10.png b/asciidoc/resources/icons/callouts/10.png
index 997bbc8..997bbc8 100644
--- a/images/icons/callouts/10.png
+++ b/asciidoc/resources/icons/callouts/10.png
Binary files differ
diff --git a/images/icons/callouts/11.png b/asciidoc/resources/icons/callouts/11.png
index ce47dac..ce47dac 100644
--- a/images/icons/callouts/11.png
+++ b/asciidoc/resources/icons/callouts/11.png
Binary files differ
diff --git a/images/icons/callouts/12.png b/asciidoc/resources/icons/callouts/12.png
index 31daf4e..31daf4e 100644
--- a/images/icons/callouts/12.png
+++ b/asciidoc/resources/icons/callouts/12.png
Binary files differ
diff --git a/images/icons/callouts/13.png b/asciidoc/resources/icons/callouts/13.png
index 14021a8..14021a8 100644
--- a/images/icons/callouts/13.png
+++ b/asciidoc/resources/icons/callouts/13.png
Binary files differ
diff --git a/images/icons/callouts/14.png b/asciidoc/resources/icons/callouts/14.png
index 64014b7..64014b7 100644
--- a/images/icons/callouts/14.png
+++ b/asciidoc/resources/icons/callouts/14.png
Binary files differ
diff --git a/images/icons/callouts/15.png b/asciidoc/resources/icons/callouts/15.png
index 0d65765..0d65765 100644
--- a/images/icons/callouts/15.png
+++ b/asciidoc/resources/icons/callouts/15.png
Binary files differ
diff --git a/images/icons/callouts/2.png b/asciidoc/resources/icons/callouts/2.png
index 5d09341..5d09341 100644
--- a/images/icons/callouts/2.png
+++ b/asciidoc/resources/icons/callouts/2.png
Binary files differ
diff --git a/images/icons/callouts/3.png b/asciidoc/resources/icons/callouts/3.png
index ef7b700..ef7b700 100644
--- a/images/icons/callouts/3.png
+++ b/asciidoc/resources/icons/callouts/3.png
Binary files differ
diff --git a/images/icons/callouts/4.png b/asciidoc/resources/icons/callouts/4.png
index adb8364..adb8364 100644
--- a/images/icons/callouts/4.png
+++ b/asciidoc/resources/icons/callouts/4.png
Binary files differ
diff --git a/images/icons/callouts/5.png b/asciidoc/resources/icons/callouts/5.png
index 4d7eb46..4d7eb46 100644
--- a/images/icons/callouts/5.png
+++ b/asciidoc/resources/icons/callouts/5.png
Binary files differ
diff --git a/images/icons/callouts/6.png b/asciidoc/resources/icons/callouts/6.png
index 0ba694a..0ba694a 100644
--- a/images/icons/callouts/6.png
+++ b/asciidoc/resources/icons/callouts/6.png
Binary files differ
diff --git a/images/icons/callouts/7.png b/asciidoc/resources/icons/callouts/7.png
index 472e96f..472e96f 100644
--- a/images/icons/callouts/7.png
+++ b/asciidoc/resources/icons/callouts/7.png
Binary files differ
diff --git a/images/icons/callouts/8.png b/asciidoc/resources/icons/callouts/8.png
index 5e60973..5e60973 100644
--- a/images/icons/callouts/8.png
+++ b/asciidoc/resources/icons/callouts/8.png
Binary files differ
diff --git a/images/icons/callouts/9.png b/asciidoc/resources/icons/callouts/9.png
index a0676d2..a0676d2 100644
--- a/images/icons/callouts/9.png
+++ b/asciidoc/resources/icons/callouts/9.png
Binary files differ
diff --git a/images/icons/caution.png b/asciidoc/resources/icons/caution.png
index 9a8c515..9a8c515 100644
--- a/images/icons/caution.png
+++ b/asciidoc/resources/icons/caution.png
Binary files differ
diff --git a/images/icons/example.png b/asciidoc/resources/icons/example.png
index 1199e86..1199e86 100644
--- a/images/icons/example.png
+++ b/asciidoc/resources/icons/example.png
Binary files differ
diff --git a/images/icons/home.png b/asciidoc/resources/icons/home.png
index 37a5231..37a5231 100644
--- a/images/icons/home.png
+++ b/asciidoc/resources/icons/home.png
Binary files differ
diff --git a/images/icons/important.png b/asciidoc/resources/icons/important.png
index be685cc..be685cc 100644
--- a/images/icons/important.png
+++ b/asciidoc/resources/icons/important.png
Binary files differ
diff --git a/images/icons/next.png b/asciidoc/resources/icons/next.png
index 64e126b..64e126b 100644
--- a/images/icons/next.png
+++ b/asciidoc/resources/icons/next.png
Binary files differ
diff --git a/images/icons/note.png b/asciidoc/resources/icons/note.png
index 7c1f3e2..7c1f3e2 100644
--- a/images/icons/note.png
+++ b/asciidoc/resources/icons/note.png
Binary files differ
diff --git a/images/icons/prev.png b/asciidoc/resources/icons/prev.png
index 3e8f12f..3e8f12f 100644
--- a/images/icons/prev.png
+++ b/asciidoc/resources/icons/prev.png
Binary files differ
diff --git a/images/icons/tip.png b/asciidoc/resources/icons/tip.png
index f087c73..f087c73 100644
--- a/images/icons/tip.png
+++ b/asciidoc/resources/icons/tip.png
Binary files differ
diff --git a/images/icons/up.png b/asciidoc/resources/icons/up.png
index 2db1ce6..2db1ce6 100644
--- a/images/icons/up.png
+++ b/asciidoc/resources/icons/up.png
Binary files differ
diff --git a/images/icons/warning.png b/asciidoc/resources/icons/warning.png
index d41edb9..d41edb9 100644
--- a/images/icons/warning.png
+++ b/asciidoc/resources/icons/warning.png
Binary files differ
diff --git a/javascripts/ASCIIMathML.js b/asciidoc/resources/javascripts/ASCIIMathML.js
index 489b312..489b312 100644
--- a/javascripts/ASCIIMathML.js
+++ b/asciidoc/resources/javascripts/ASCIIMathML.js
diff --git a/javascripts/LaTeXMathML.js b/asciidoc/resources/javascripts/LaTeXMathML.js
index 51dba70..51dba70 100644
--- a/javascripts/LaTeXMathML.js
+++ b/asciidoc/resources/javascripts/LaTeXMathML.js
diff --git a/javascripts/asciidoc.js b/asciidoc/resources/javascripts/asciidoc.js
index ac36563..ac36563 100644
--- a/javascripts/asciidoc.js
+++ b/asciidoc/resources/javascripts/asciidoc.js
diff --git a/javascripts/slidy.js b/asciidoc/resources/javascripts/slidy.js
index 04e51a2..04e51a2 100644
--- a/javascripts/slidy.js
+++ b/asciidoc/resources/javascripts/slidy.js
diff --git a/javascripts/toc.js b/asciidoc/resources/javascripts/toc.js
index 06127bf..06127bf 100644
--- a/javascripts/toc.js
+++ b/asciidoc/resources/javascripts/toc.js
diff --git a/lang-ca.conf b/asciidoc/resources/lang-ca.conf
index 0dcdf49..0dcdf49 100644
--- a/lang-ca.conf
+++ b/asciidoc/resources/lang-ca.conf
diff --git a/lang-cs.conf b/asciidoc/resources/lang-cs.conf
index ee4052c..ee4052c 100644
--- a/lang-cs.conf
+++ b/asciidoc/resources/lang-cs.conf
diff --git a/lang-de.conf b/asciidoc/resources/lang-de.conf
index 5364c59..5364c59 100644
--- a/lang-de.conf
+++ b/asciidoc/resources/lang-de.conf
diff --git a/lang-el.conf b/asciidoc/resources/lang-el.conf
index f9a2714..f9a2714 100644
--- a/lang-el.conf
+++ b/asciidoc/resources/lang-el.conf
diff --git a/lang-en.conf b/asciidoc/resources/lang-en.conf
index d304fcb..d304fcb 100644
--- a/lang-en.conf
+++ b/asciidoc/resources/lang-en.conf
diff --git a/lang-es.conf b/asciidoc/resources/lang-es.conf
index da9a3bb..da9a3bb 100644
--- a/lang-es.conf
+++ b/asciidoc/resources/lang-es.conf
diff --git a/lang-fi.conf b/asciidoc/resources/lang-fi.conf
index 2af8769..2af8769 100644
--- a/lang-fi.conf
+++ b/asciidoc/resources/lang-fi.conf
diff --git a/lang-fr.conf b/asciidoc/resources/lang-fr.conf
index 8b708f6..8b708f6 100644
--- a/lang-fr.conf
+++ b/asciidoc/resources/lang-fr.conf
diff --git a/lang-hu.conf b/asciidoc/resources/lang-hu.conf
index c9a2906..c9a2906 100644
--- a/lang-hu.conf
+++ b/asciidoc/resources/lang-hu.conf
diff --git a/lang-id.conf b/asciidoc/resources/lang-id.conf
index f2bcbc2..f2bcbc2 100644
--- a/lang-id.conf
+++ b/asciidoc/resources/lang-id.conf
diff --git a/lang-it.conf b/asciidoc/resources/lang-it.conf
index 52e083f..52e083f 100644
--- a/lang-it.conf
+++ b/asciidoc/resources/lang-it.conf
diff --git a/lang-ja.conf b/asciidoc/resources/lang-ja.conf
index 5ff71df..5ff71df 100644
--- a/lang-ja.conf
+++ b/asciidoc/resources/lang-ja.conf
diff --git a/lang-nl.conf b/asciidoc/resources/lang-nl.conf
index 32a27e2..32a27e2 100644
--- a/lang-nl.conf
+++ b/asciidoc/resources/lang-nl.conf
diff --git a/lang-pl.conf b/asciidoc/resources/lang-pl.conf
index 7bb6d87..7bb6d87 100644
--- a/lang-pl.conf
+++ b/asciidoc/resources/lang-pl.conf
diff --git a/lang-pt-BR.conf b/asciidoc/resources/lang-pt-BR.conf
index 21981db..21981db 100644
--- a/lang-pt-BR.conf
+++ b/asciidoc/resources/lang-pt-BR.conf
diff --git a/lang-ro.conf b/asciidoc/resources/lang-ro.conf
index cb63af2..cb63af2 100644
--- a/lang-ro.conf
+++ b/asciidoc/resources/lang-ro.conf
diff --git a/lang-ru.conf b/asciidoc/resources/lang-ru.conf
index 8e66e3e..8e66e3e 100644
--- a/lang-ru.conf
+++ b/asciidoc/resources/lang-ru.conf
diff --git a/lang-sv.conf b/asciidoc/resources/lang-sv.conf
index 2157089..2157089 100644
--- a/lang-sv.conf
+++ b/asciidoc/resources/lang-sv.conf
diff --git a/lang-uk.conf b/asciidoc/resources/lang-uk.conf
index fa6abad..fa6abad 100644
--- a/lang-uk.conf
+++ b/asciidoc/resources/lang-uk.conf
diff --git a/lang-zh-CN.conf b/asciidoc/resources/lang-zh-CN.conf
index 9dfd82f..9dfd82f 100644
--- a/lang-zh-CN.conf
+++ b/asciidoc/resources/lang-zh-CN.conf
diff --git a/latex.conf b/asciidoc/resources/latex.conf
index eadf207..eadf207 100644
--- a/latex.conf
+++ b/asciidoc/resources/latex.conf
diff --git a/slidy.conf b/asciidoc/resources/slidy.conf
index 32a9098..32a9098 100644
--- a/slidy.conf
+++ b/asciidoc/resources/slidy.conf
diff --git a/stylesheets/asciidoc.css b/asciidoc/resources/stylesheets/asciidoc.css
index 55e6384..55e6384 100644
--- a/stylesheets/asciidoc.css
+++ b/asciidoc/resources/stylesheets/asciidoc.css
diff --git a/stylesheets/docbook-xsl.css b/asciidoc/resources/stylesheets/docbook-xsl.css
index ee9ca46..ee9ca46 100644
--- a/stylesheets/docbook-xsl.css
+++ b/asciidoc/resources/stylesheets/docbook-xsl.css
diff --git a/stylesheets/pygments.css b/asciidoc/resources/stylesheets/pygments.css
index 2c5a906..2c5a906 100644
--- a/stylesheets/pygments.css
+++ b/asciidoc/resources/stylesheets/pygments.css
diff --git a/stylesheets/slidy.css b/asciidoc/resources/stylesheets/slidy.css
index bbb790e..bbb790e 100644
--- a/stylesheets/slidy.css
+++ b/asciidoc/resources/stylesheets/slidy.css
diff --git a/stylesheets/toc2.css b/asciidoc/resources/stylesheets/toc2.css
index c6e63f5..c6e63f5 100644
--- a/stylesheets/toc2.css
+++ b/asciidoc/resources/stylesheets/toc2.css
diff --git a/stylesheets/xhtml11-quirks.css b/asciidoc/resources/stylesheets/xhtml11-quirks.css
index b793527..b793527 100644
--- a/stylesheets/xhtml11-quirks.css
+++ b/asciidoc/resources/stylesheets/xhtml11-quirks.css
diff --git a/text.conf b/asciidoc/resources/text.conf
index 7bc6658..7bc6658 100644
--- a/text.conf
+++ b/asciidoc/resources/text.conf
diff --git a/themes/flask/flask.css b/asciidoc/resources/themes/flask/flask.css
index b8c9c4d..b8c9c4d 100644
--- a/themes/flask/flask.css
+++ b/asciidoc/resources/themes/flask/flask.css
diff --git a/themes/volnitsky/volnitsky.css b/asciidoc/resources/themes/volnitsky/volnitsky.css
index 8b74dc7..8b74dc7 100644
--- a/themes/volnitsky/volnitsky.css
+++ b/asciidoc/resources/themes/volnitsky/volnitsky.css
diff --git a/xhtml11-quirks.conf b/asciidoc/resources/xhtml11-quirks.conf
index cd6c41e..cd6c41e 100644
--- a/xhtml11-quirks.conf
+++ b/asciidoc/resources/xhtml11-quirks.conf
diff --git a/xhtml11.conf b/asciidoc/resources/xhtml11.conf
index 38633e1..38633e1 100644
--- a/xhtml11.conf
+++ b/asciidoc/resources/xhtml11.conf
diff --git a/asciidocapi.py b/asciidocapi.py
deleted file mode 100644
index a5a29bd..0000000
--- a/asciidocapi.py
+++ /dev/null
@@ -1,308 +0,0 @@
-#!/usr/bin/env python3
-"""
-asciidocapi - AsciiDoc API wrapper class.
-
-The AsciiDocAPI class provides an API for executing asciidoc. Minimal example
-compiles `mydoc.txt` to `mydoc.html`:
-
- import asciidocapi
- asciidoc = asciidocapi.AsciiDocAPI()
- asciidoc.execute('mydoc.txt')
-
-- Full documentation in asciidocapi.txt.
-- See the doctests below for more examples.
-
-Doctests:
-
-1. Check execution:
-
- >>> import io
- >>> infile = io.StringIO('Hello *{author}*')
- >>> outfile = io.StringIO()
- >>> asciidoc = AsciiDocAPI()
- >>> asciidoc.options('--no-header-footer')
- >>> asciidoc.attributes['author'] = 'Joe Bloggs'
- >>> asciidoc.execute(infile, outfile, backend='html4')
- >>> print(outfile.getvalue())
- <p>Hello <strong>Joe Bloggs</strong></p>
-
- >>> asciidoc.attributes['author'] = 'Bill Smith'
- >>> infile = io.StringIO('Hello _{author}_')
- >>> outfile = io.StringIO()
- >>> asciidoc.execute(infile, outfile, backend='docbook')
- >>> print(outfile.getvalue())
- <simpara>Hello <emphasis>Bill Smith</emphasis></simpara>
-
-2. Check error handling:
-
- >>> import io
- >>> asciidoc = AsciiDocAPI()
- >>> infile = io.StringIO('---------')
- >>> outfile = io.StringIO()
- >>> asciidoc.execute(infile, outfile)
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- File "asciidocapi.py", line 189, in execute
- raise AsciiDocError(self.messages[-1])
- AsciiDocError: ERROR: <stdin>: line 1: [blockdef-listing] missing closing delimiter
-
-
-Copyright (C) 2002-2013 Stuart Rackham.
-Copyright (C) 2013-2020 AsciiDoc Contributors.
-
-Free use of this software is granted under the terms of the GNU General
-Public License version 2 (GPLv2).
-
-"""
-
-import sys
-import os
-import re
-
-API_VERSION = '0.1.2'
-MIN_ASCIIDOC_VERSION = '8.4.1' # Minimum acceptable AsciiDoc version.
-
-
-def find_in_path(fname, path=None):
- """
- Find file fname in paths. Return None if not found.
- """
- if path is None:
- path = os.environ.get('PATH', '')
- for dir in path.split(os.pathsep):
- fpath = os.path.join(dir, fname)
- if os.path.isfile(fpath):
- return fpath
- else:
- return None
-
-
-class AsciiDocError(Exception):
- pass
-
-
-class Options(object):
- """
- Stores asciidoc(1) command options.
- """
- def __init__(self, values=[]):
- self.values = values[:]
-
- def __call__(self, name, value=None):
- """Shortcut for append method."""
- self.append(name, value)
-
- def append(self, name, value=None):
- if type(value) in (int, float):
- value = str(value)
- self.values.append((name, value))
-
-
-class Version(object):
- """
- Parse and compare AsciiDoc version numbers. Instance attributes:
-
- string: String version number '<major>.<minor>[.<micro>][suffix]'.
- major: Integer major version number.
- minor: Integer minor version number.
- micro: Integer micro version number.
- suffix: Suffix (begins with non-numeric character) is ignored when
- comparing.
-
- Doctest examples:
-
- >>> Version('8.2.5') < Version('8.3 beta 1')
- True
- >>> Version('8.3.0') == Version('8.3. beta 1')
- True
- >>> Version('8.2.0') < Version('8.20')
- True
- >>> Version('8.20').major
- 8
- >>> Version('8.20').minor
- 20
- >>> Version('8.20').micro
- 0
- >>> Version('8.20').suffix
- ''
- >>> Version('8.20 beta 1').suffix
- 'beta 1'
-
- """
- def __init__(self, version):
- self.string = version
- reo = re.match(r'^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$', self.string)
- if not reo:
- raise ValueError('invalid version number: %s' % self.string)
- groups = reo.groups()
- self.major = int(groups[0])
- self.minor = int(groups[1])
- self.micro = int(groups[3] or '0')
- self.suffix = groups[4] or ''
-
- def __lt__(self, other):
- if self.major < other.major:
- return True
-
- elif self.major == other.major:
- if self.minor < other.minor:
- return True
- elif self.minor == other.minor:
- if self.micro < other.micro:
- return True
- return False
-
- # (sigh). Copy-paste
- def __le__(self, other):
- if self.major > other.major:
- return False
-
- elif self.major <= other.major:
- if self.minor > other.minor:
- return False
- elif self.minor <= other.minor:
- if self.micro > other.micro:
- return False
- return True
-
- def __eq__(self, other):
- if self.major == other.major \
- and self.minor == other.minor \
- and self.micro == other.micro:
- return True
-
- return False
-
-
-class AsciiDocAPI(object):
- """
- AsciiDoc API class.
- """
- def __init__(self, asciidoc_py=None):
- """
- Locate and import asciidoc.py.
- Initialize instance attributes.
- """
- self.options = Options()
- self.attributes = {}
- self.messages = []
- # Search for the asciidoc command file in that order :
- # - ASCIIDOC_PY environment variable
- # - asciidoc_py function argument
- # - sibling (preferred to shell search paths, to ensure version matching)
- # - shell search paths
- cmd = os.environ.get('ASCIIDOC_PY')
- if cmd:
- if not os.path.isfile(cmd):
- raise AsciiDocError('missing ASCIIDOC_PY file: %s' % cmd)
- elif asciidoc_py:
- # Next try path specified by caller.
- cmd = asciidoc_py
- if not os.path.isfile(cmd):
- raise AsciiDocError('missing file: %s' % cmd)
- else:
- # try to find sibling paths
- this_path = os.path.dirname(os.path.realpath(__file__))
- for fname in ['asciidoc.py', 'asciidoc.pyc', 'asciidoc']:
- cmd = find_in_path(fname, path=this_path)
- if cmd:
- break
- else:
- # Try shell search paths.
- for fname in ['asciidoc.py', 'asciidoc.pyc', 'asciidoc']:
- cmd = find_in_path(fname)
- if cmd:
- break
- else:
- # Finally try current working directory.
- for cmd in ['asciidoc.py', 'asciidoc.pyc', 'asciidoc']:
- if os.path.isfile(cmd):
- break
- else:
- raise AsciiDocError('failed to locate asciidoc')
- self.cmd = os.path.realpath(cmd)
- self.__import_asciidoc()
-
- def __import_asciidoc(self, reload=False):
- '''
- Import asciidoc module (script or compiled .pyc).
- See
- http://groups.google.com/group/asciidoc/browse_frm/thread/66e7b59d12cd2f91
- for an explanation of why a seemingly straight-forward job turned out
- quite complicated.
- '''
- if os.path.splitext(self.cmd)[1] in ['.py', '.pyc']:
- sys.path.insert(0, os.path.dirname(self.cmd))
- try:
- try:
- if reload:
- import importlib # Because reload() is shadowed.
- importlib.reload(self.asciidoc)
- else:
- import asciidoc
- self.asciidoc = asciidoc
- except ImportError:
- raise AsciiDocError('failed to import ' + self.cmd)
- finally:
- del sys.path[0]
- else:
- # The import statement can only handle .py or .pyc files, have to
- # use importlib for scripts with other names.
- try:
- from importlib.util import spec_from_loader, module_from_spec
- from importlib.machinery import SourceFileLoader
- loader = SourceFileLoader('asciidoc', self.cmd)
- spec = spec_from_loader('asciidoc', loader)
- module = module_from_spec(spec)
- spec.loader.exec_module(module)
- self.asciidoc = module
- except ImportError:
- raise AsciiDocError('failed to import ' + self.cmd)
- if Version(self.asciidoc.VERSION) < Version(MIN_ASCIIDOC_VERSION):
- raise AsciiDocError(
- 'asciidocapi %s requires asciidoc %s or better'
- % (API_VERSION, MIN_ASCIIDOC_VERSION))
-
- def execute(self, infile, outfile=None, backend=None):
- """
- Compile infile to outfile using backend format.
- infile can outfile can be file path strings or file like objects.
- """
- self.messages = []
- opts = Options(self.options.values)
- if outfile is not None:
- opts('--out-file', outfile)
- if backend is not None:
- opts('--backend', backend)
- for k, v in self.attributes.items():
- if v == '' or k[-1] in '!@':
- s = k
- elif v is None: # A None value undefines the attribute.
- s = k + '!'
- else:
- s = '%s=%s' % (k, v)
- opts('--attribute', s)
- args = [infile]
- # The AsciiDoc command was designed to process source text then
- # exit, there are globals and statics in asciidoc.py that have
- # to be reinitialized before each run -- hence the reload.
- self.__import_asciidoc(reload=True)
- try:
- try:
- self.asciidoc.execute(self.cmd, opts.values, args)
- finally:
- self.messages = self.asciidoc.messages[:]
- except SystemExit as e:
- if e.code:
- raise AsciiDocError(self.messages[-1])
-
-
-if __name__ == "__main__":
- """
- Run module doctests.
- """
- import doctest
- options = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
- test_result = doctest.testmod(optionflags=options)
- print(test_result)
- sys.exit(test_result.failed > 0)
diff --git a/build_manifest.sh b/build_manifest.sh
deleted file mode 100644
index 2b9f874..0000000
--- a/build_manifest.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-rm -f MANIFEST
-while read in; do
- if [ ! -z "${in}" ]; then
- ls -1A ${in} >> MANIFEST
- fi
-done < MANIFEST.in
-echo "MANIFEST" >> MANIFEST
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..bcf2d5e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Note: To use the 'upload' functionality of this file, you must:
+# $ pip install twine
+
+import io
+import os
+import sys
+from shutil import rmtree
+
+from setuptools import find_packages, setup, Command
+
+# Package meta-data.
+NAME = 'asciidoc'
+DESCRIPTION = 'AsciiDoc is a text document format for writing things.'
+URL = 'https://github.com/asciidoc/asciidoc-py3'
+AUTHOR = 'asciidoc team'
+REQUIRES_PYTHON = '>=3.4.0'
+
+# The rest you shouldn't have to touch too much :)
+# ------------------------------------------------
+# Except, perhaps the License and Trove Classifiers!
+# If you do change the License, remember to change the Trove Classifier
+# for that!
+
+here = os.path.abspath(os.path.dirname(__file__))
+
+# Import the README and use it as the long-description.
+# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
+try:
+ with io.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
+ long_description = '\n' + f.read()
+except FileNotFoundError:
+ long_description = DESCRIPTION
+
+# Load the package's __metadata__.py module as a dictionary.
+about = {}
+with open(os.path.join(here, NAME, '__metadata__.py')) as f:
+ exec(f.read(), about)
+
+
+class UploadCommand(Command):
+ """Support setup.py upload."""
+
+ description = 'Build and publish the package.'
+ user_options = []
+
+ @staticmethod
+ def status(s):
+ """Prints things in bold."""
+ print('\033[1m{0}\033[0m'.format(s))
+
+ def initialize_options(self):
+ pass
+
+ def finalize_options(self):
+ pass
+
+ def run(self):
+ try:
+ self.status('Removing previous builds…')
+ rmtree(os.path.join(here, 'dist'))
+ except OSError:
+ pass
+
+ self.status('Building Source and Wheel (universal) distribution…')
+ os.system('{0} setup.py sdist bdist_wheel --universal'.format(
+ sys.executable
+ ))
+
+ self.status('Uploading the package to PyPI via Twine…')
+ os.system('twine upload dist/*')
+
+ self.status('Pushing git tags…')
+ os.system('git tag v{0}'.format(about['__version__']))
+ os.system('git push --tags')
+
+ sys.exit()
+
+
+# Where the magic happens:
+setup(
+ name=NAME,
+ version=about['__version__'],
+ description=DESCRIPTION,
+ long_description=long_description,
+ author=AUTHOR,
+ python_requires=REQUIRES_PYTHON,
+ url=URL,
+ packages=find_packages(exclude=('tests',)),
+ entry_points={
+ 'console_scripts': [
+ 'asciidoc=asciidoc.asciidoc:cli',
+ 'a2x=asciidoc.a2x:cli'
+ ],
+ },
+ include_package_data=True,
+ license='GPLv2',
+ classifiers=[
+ # Trove classifiers
+ # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers
+ 'License :: OSI Approved :: GNU General Public License v2 (GPLv2)',
+ 'License :: OSI Approved :: MIT License',
+ 'Programming Language :: Python',
+ 'Programming Language :: Python :: 3',
+ 'Programming Language :: Python :: 3.5',
+ 'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
+ 'Programming Language :: Python :: 3.8',
+ 'Programming Language :: Python :: Implementation :: CPython',
+ ],
+ # $ setup.py publish support.
+ cmdclass={
+ 'upload': UploadCommand,
+ },
+)
diff --git a/tests/testasciidoc.conf b/tests/testasciidoc.conf
index f721598..4c3ca82 100644
--- a/tests/testasciidoc.conf
+++ b/tests/testasciidoc.conf
@@ -77,7 +77,7 @@ article-data-uri
['--section-numbers']
% attributes
-{'docdate':None, 'data-uri':True, 'icons':True, 'imagesdir': '../', 'iconsdir': '../images/icons'}
+{'docdate':None, 'data-uri':True, 'icons':True, 'imagesdir': '../'}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Example article with included docinfo file.
diff --git a/tests/testasciidoc.py b/tests/testasciidoc.py
index a6c5c1c..aec34aa 100755
--- a/tests/testasciidoc.py
+++ b/tests/testasciidoc.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
-__version__ = '0.3.0'
+__version__ = '0.4.0'
import difflib
@@ -12,7 +12,7 @@ import shutil
import sys
sys.path.append(str(Path(__file__).resolve().parent.parent))
-import asciidocapi # noqa: E402
+from asciidoc import asciidoc # noqa: E402
# Default backends.
BACKENDS = ('html4', 'xhtml11', 'docbook', 'docbook5', 'html5')
@@ -182,12 +182,20 @@ class AsciiDocTest(object):
"""
Generate and return test data output for backend.
"""
- asciidoc = asciidocapi.AsciiDocAPI()
- asciidoc.options.values = self.options
- asciidoc.attributes = self.attributes
- infile = self.source
+ asciidoc.reset_asciidoc()
outfile = io.StringIO()
- asciidoc.execute(infile, outfile, backend)
+ options = self.options[:]
+ options.append(('--out-file', outfile))
+ options.append(('--backend', backend))
+ for k, v in self.attributes.items():
+ if v == '' or k[-1] in '!@':
+ s = str(k)
+ elif v is None:
+ s = k + '!'
+ else:
+ s = '%s=%s' % (k, v)
+ options.append(('--attribute', s))
+ asciidoc.execute('asciidoc', options, [self.source])
return outfile.getvalue().splitlines(keepends=True)
def update_expected(self, backend):