GitLab Commit is coming up on August 3-4. Learn how to innovate together using GitLab, the DevOps platform. Register for free: gitlabcommitvirtual2021.com

Commit 475cad41 authored by asciidoc3's avatar asciidoc3
Browse files

Merge branch 'master' into 'master'

minor editing

See merge request !41
parents eb3401f3 226a3d50
......@@ -32,6 +32,9 @@ images/latexmath_source.png
tests/extended_tests
tests/data/a2x3testdata
tests/docbook_validation/sun_msv_jar_files
tests/docbook_validation/docbook.rng
tests/docbook_validation/rng-docbook.rng
tests/docbook_validation/schematron/
.project
.pydevproject
......@@ -824,7 +824,7 @@ def system(name, args, is_macro=False, attrs=None):
it's a system attribute.
The attrs dictionary is updated by the counter and set system attributes.
NOTE: The include1 attribute is used internally by the include1::[] macro
and is not for public use.
and is not for public use.
"""
if is_macro:
syntax = '%s::[%s]' % (name, args)
......@@ -1313,7 +1313,7 @@ class Ad3In(Ad3Codec):
super().__init__()
Ad3In.ad3in_counter += 1
if Ad3In.ad3in_counter != 1:
raise EAsciiDoc('Class Ad3In: Only one instance allowed')
raise EAsciiDoc('Class Ad3In: only one instance allowed')
self._ie = 'utf-8'
self._ierr = 'strict'
self.update_ie_allowed = True
......@@ -1378,6 +1378,7 @@ class Ad3In(Ad3Codec):
elif fname.rstrip().lower().endswith('.py'):
return 'utf-8'
elif fname.lower() == 'stdin':
self.block_updating()
if 'stdin'.lower() == document.attributes['infile']:
return self._ie
else:
......@@ -1385,7 +1386,6 @@ class Ad3In(Ad3Codec):
return getdefaultlocale()[1]
except (OSError, SystemError):
return 'utf-8'
self.block_updating()
# AsciiDoc3 opens 'infile' and/or a file not ending with conf/css/py
elif fname == document.attributes['infile'] or \
not (fname.rstrip().lower().endswith('.conf') or
......@@ -1459,12 +1459,12 @@ class Ad3In(Ad3Codec):
self.update_ie_allowed = False
self.update_ierr_allowed = False
east_asian_widths = {'W': 2, # Wide
'F': 2, # Full-width (wide)
east_asian_widths = {'W': 2, # Wide
'F': 2, # Full-width (wide)
'Na': 1, # Narrow
'H': 1, # Half-width (narrow)
'N': 1, # Neutral (not East Asian, treated as narrow)
'A': 1} # Ambiguous (s/b wide in East Asian context,
'H': 1, # Half-width (narrow)
'N': 1, # Neutral (not EastAsian, treated as narrow)
'A': 1} # Ambiguous (s/b wide in EastAsian context,
# narrow otherwise, but that doesn't work)
"""Mapping of result codes from 'unicodedata.east_asian_width()' to character
column widths."""
......@@ -1489,7 +1489,7 @@ class Ad3Out(Ad3Codec):
super().__init__()
Ad3Out.ad3out_counter += 1
if Ad3Out.ad3out_counter != 1:
raise EAsciiDoc('class Ad3Out: Only one instance allowed')
raise EAsciiDoc('class Ad3Out: only one instance allowed')
self._oe = 'utf-8' # this is the default
self._oerr = 'strict' # this is the default
self.update_oe_allowed = True
......@@ -6234,7 +6234,7 @@ class Plugin:
# ---------
APP_FILE = None # This file's full path.
APP_DIR = None # This file's directory.
USER_DIR = None # ~/.asciidoc
USER_DIR = None # ~/.asciidoc3
# Global configuration files directory (set by Makefile build target).
CONF_DIR = '/etc/asciidoc3'
HELP_FILE = 'help.conf' # Default (English) help file.
......
......@@ -74,10 +74,13 @@ endif::basebackend-html[]
ifdef::basebackend-html4[]
[source-filter-style]
# html4 does not use pygments.
# html4 does not use pygments, but the code is given to avoid the warning message 'missing macro'.
ifeval::["{source-highlighter}"=="source-highlight"]
source-style=template="source-highlight-block",presubs=(),postsubs=("callouts",),posattrs=("style","language","src_numbered","src_tab"),filter="source-highlight -f html -s {language} {src_numbered?--line-number=' '} {src_tab?--tab={src_tab}} {args=}"
endif::[]
ifeval::["{source-highlighter}"=="pygments"]
source-style=template="source-highlight-block",presubs=(),postsubs=("callouts",),posattrs=("style","language","src_numbered"),filter="pygmentize -f html -l {language} {src_numbered?-O linenos=table} {encoding?-O encoding={encoding}} {args=}"
endif::[]
ifeval::["{source-highlighter}"=="highlight"]
source-style=template="source-highlight-block",presubs=(),postsubs=("callouts",),posattrs=("style","language","src_numbered","src_tab"),filter="highlight --no-doc --inline-css --out-format=html --syntax={language@python:py:{language}} {src_numbered?--line-number} {src_tab?--tab={src_tab}} {args=}"
endif::[]
......
#!/usr/bin/env python3
"""
Runs a bunch of a2x3.py testcases over alle txt-files in directory
Run a bunch of a2x3.py testcases over alle txt-files in directory
./tests/data/
to produce PDFs via, first, dblatex and, secons, via Apache FOP.
to produce PDFs via, first, dblatex and, second, via Apache FOP.
Usage: python3 a2x3_multitest.py
You have to start the progran in directory './tests'
You'll see some errors because of not all documents are
valid DocBook. That's not a bug (nonvalid_docbook51.xml, newtables_docbook51
Usage:
[cd ./tests && \]
python3 a2x3_multitest.py
You'll see some errors since not all documents are valid DocBook.
That's not a bug (nonvalid_docbook51.xml, newtables_docbook51
at al.), it's the expected behavior.
Copyright (C) 2020 by Berthold Gehrke <berthold.gehrke@gmail.com>
......@@ -16,42 +20,55 @@ Free use of this software is granted under the terms of the
GNU General Public License Version 2 or higher (GNU GPLv2+).
"""
from argparse import ArgumentParser
from concurrent import futures
import os
import subprocess
from shutil import copy
DESCRIPTION = """\
Run tests for AsciiDoc3 'a2x3'
Use option '-v' to see a2x3 working.
Don't forget to change to directory ./test !
"""
ARG_PARSER = ArgumentParser(usage='usage: [cd ./tests &&] \
[python3 testasciidoc3.py --force update &&] \
python3 multitest_a2x3.py', description=DESCRIPTION)
ARG_PARSER.add_argument('-v', '--verbose', action='store_true', default=False,
help='see more output or debugging')
ARGS = ARG_PARSER.parse_args()
def a2x3_multi(testfile):
'''
"""
TODO
'''
"""
if testfile.endswith('_fop.txt'):
subprocess.run(["python3", "../a2x3.py", "-f", "pdf", "--fop", path_to_data + testfile])
subprocess.run(["a2x3", "-f", "pdf", "--fop", path_to_data + testfile])
else:
subprocess.run(["python3", "../a2x3.py", "-f", "pdf", path_to_data + testfile])
subprocess.run(["a2x3", "-f", "pdf", path_to_data + testfile])
def data_files():
'''
"""
TODO
'''
"""
testfiles = list()
with os.scandir(path_to_data) as testpath:
for entry in testpath:
if entry.name.endswith('.txt'):
testfiles.append(entry.name)
filename_short = entry.name[:-4]
copy('data/' + entry.name,
'data/' + filename_short + '_fop.txt')
copy(add_dockerpath+'data/' + entry.name,
add_dockerpath+'data/' + filename_short + '_fop.txt')
testfiles.append(filename_short + '_fop.txt')
return tuple(testfiles)
def del_files():
'''
Remove files to have an "empty workspace"
'''
def remove_files():
"""
Remove files to have an empty workspace.
"""
artifacts_to_remove = (
'latex1.md5',
'latex1.png',
......@@ -83,8 +100,8 @@ def del_files():
'open-block-test__3.png',
'slidy-example__1.png',)
for item in artifacts_to_remove:
if os.path.exists("../images/" + item):
os.remove("../images/" + item)
if os.path.exists(ad3dir+"images/" + item):
os.remove(ad3dir+"images/" + item)
with os.scandir(path_to_data) as testpath:
for entry in testpath:
if entry.name.endswith('_fop.txt'):
......@@ -98,22 +115,36 @@ def del_files():
else:
pass
def main(item):
'''
TODO
'''
print(item)
""" Start test for item from 'datafile' """
if ARGS.verbose:
print(item)
a2x3_multi(item)
if __name__ == "__main__":
'''do not run as an imported module or using an IDE like IDLE'''
"""\
When running inside a container, we need to alter the paths.
"""
add_dockerpath = ''
ad3dir = '../'
if os.path.exists('/.dockerenv'):
path_to_testa2x3_py = os.getcwd()+"/"+__file__
testdir = os.path.dirname(path_to_testa2x3_py)+"/"
add_dockerpath = testdir
ad3dir = testdir[:-6]
if ARGS.verbose:
print("Found '/.dockerenv': working inside a container.")
else:
if ARGS.verbose:
print("No container found.")
full_path = os.path.abspath(os.path.dirname(__file__))
path_to_data = full_path + "/data/"
del_files()
remove_files()
# to remove only the 'test artifacts',
# comment out the next three lines
TUPLE_TEST = data_files()
with futures.ProcessPoolExecutor(max_workers=4) as e:
with futures.ProcessPoolExecutor(max_workers=3) as e:
for item in TUPLE_TEST:
e.submit(main, item)
#!/usr/bin/env python3
"""
Runs a bunch of a2x3.py testcases analogue to 'testasciidoc3.py'
(which tests asciidoc3.py). First some files are copied to
./tests/data/a2x3testdata
In a second step a2x3.py is executed in diverse approaches. See the
'command lines' presented as 'TEST_TUPEL'.
Be sure to have all needed programs installed: lynx, w3m, epubcheck,
dblatex, fop ...
Before you can use testa2x3.py you have to run
"""\
Run a bunch of 'a2x3' testcases analogue to 'testasciidoc3.py'
(which tests asciidoc3.py).
First some files are copied to ./tests/data/a2x3testdata, in a
second step a2x3 is executed in diverse approaches.
See the 'command lines' presented as 'TEST_TUPLE'.
Be sure to have all needed programs installed: dblatex, lynx,
w3m, epubcheck, dblatex, fop ...
Before you can run testa2x3.py you have to start
'python3 testasciidoc3.py --force update'
to produce the testfiles. Output is written to
'./tests/data/a2x3testdata/'
Usage: [python3 testasciidoc3.py --force update &&] python3 testa2x3.py [-v]
You have to start this program from inside the 'tests' directory:
[cd ./tests]
Usage
[cd ./tests &&] \
[python3 testasciidoc3.py --force update &&] \
python3 testa2x3.py [-v]
Known bugs:
Docker
When using the AsciiDoc3 Docker-Container:
'docker run ... asciidoc3:full python3 tests/testasciidoc3.py --force update'
and then
'docker run ... asciidoc3:full python3 tests/testa2x3.py [-v]'
Known bugs
If producing dvi/ps, the source must not contain images - this seems to
be a dblatex issue ... (?)
be a 'dblatex' issue ... (?)
Copyright (C) 2020 by Berthold Gehrke <berthold.gehrke@gmail.com>
Free use of this software is granted under the terms of the
......@@ -32,105 +44,84 @@ import shutil
import subprocess
TEST_TUPEL = (
# txt to pdf
['-f', 'pdf', './data/a2x3testdata/pdf_test.txt'],
# txt to pdf using fop
['-f', 'pdf', '--fop', './data/a2x3testdata/fop_test.txt'],
# txt to epub
['-f', 'epub', './data/a2x3testdata/epub_test.txt'],
# txt to epub leave artifacts
['-f', 'epub', '-k', './data/a2x3testdata/epub_artifacts_test.txt'],
# txt to epub epubcheck
# ['-f', 'epub', '-k', '--epubcheck', \
# './data/a2x3testdata/epubcheck_test.txt'],
# txt to text (lynx)
['-f', 'text', '--lynx', './data/a2x3testdata/lynx_test.txt'],
# txt to text (w3m)
['-f', 'text', './data/a2x3testdata/w3m_test.txt'],
# txt to xhtml
['-f', 'xhtml', './data/a2x3testdata/test.txt'],
# txt to manpage
['-f', 'manpage', '-d', 'manpage', './data/a2x3testdata/a2x3.1.txt'],
# txt to docbook xml
['-f', 'docbook', './data/a2x3testdata/docbook_test.txt'],
# xml (docbook) to pdf
['-f', 'pdf', './data/a2x3testdata/test-docbook45.xml'],
# txt to chunked
['-f', 'chunked', './data/a2x3testdata/chunked_test.txt'],
# xml (docbook) to dvi
['-f', 'dvi', './data/a2x3testdata/faq_dvi_test_45.xml'],
# xml (docbook) to ps
['-f', 'ps', './data/a2x3testdata/faq_ps_test_51.xml'],
# xml (docbook) to tex
['-f', 'tex', './data/a2x3testdata/tex_test_51.xml'],
)
DESCRIPTION = '''Runs tests for AsciiDoc3 / a2x3.py.
Use option '-v' to see a2x3 working.'''
ARG_PARSER = ArgumentParser(usage='usage: python3 a2x3test.py [-v]',
DESCRIPTION = """\
Run tests for AsciiDoc3 'a2x3'
Use option '-v' to see a2x3 working.
Don't forget to change to directory ./test !
"""
ARG_PARSER = ArgumentParser(usage='usage: [cd ./tests &&] \
[python3 testasciidoc3.py --force update &&] \
python3 testa2x3.py [-v]',
description=DESCRIPTION)
ARG_PARSER.add_argument('-v', '--verbose', action='store_true', default=False,
help='see more output')
help='see more output or debugging')
ARGS = ARG_PARSER.parse_args()
def remove_testitems():
"""remove files from previous tests"""
if os.path.exists('./data/a2x3testdata/'):
shutil.rmtree('./data/a2x3testdata/')
"""Remove files from previous tests"""
if os.path.exists(add_dockerpath+'data/a2x3testdata/'):
shutil.rmtree(add_dockerpath+'data/a2x3testdata/')
if ARGS.verbose:
print("remove ./data/a2x3testdata/")
print("remove data/a2x3testdata/")
def copy_testfiles():
"""Copy files to ./data/a2x3testdata/"""
os.mkdir('./data/a2x3testdata/')
"""Copy files to data/a2x3testdata/"""
os.mkdir(add_dockerpath+'data/a2x3testdata/')
for file_item in ('test.txt',
'a2x3.1.txt',
):
if os.path.exists('../doc/'+file_item):
shutil.copy2('../doc/'+file_item, './data/a2x3testdata/'+file_item)
if os.path.exists(ad3dir+'doc/'+file_item):
shutil.copy2(ad3dir+'doc/'+file_item,
add_dockerpath+'data/a2x3testdata/'+file_item)
if ARGS.verbose:
print("copy "+file_item)
# We use copies of 'test.txt' to test text, pdf, fop, epub, epubcheck ...'
if os.path.exists('./data/a2x3testdata/test.txt'):
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/pdf_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/fop_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/lynx_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/w3m_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/fop_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/epub_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/epub_artifacts_test.txt')
# shutil.copy2('./data/a2x3testdata/test.txt',
# './data/a2x3testdata/epubcheck_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/docbook_test.txt')
shutil.copy2('./data/a2x3testdata/test.txt',
'./data/a2x3testdata/chunked_test.txt')
shutil.copy2('./data/test-docbook45.xml',
'./data/a2x3testdata/test-docbook45.xml')
shutil.copy2('./data/faq-docbook45.xml',
'./data/a2x3testdata/faq_dvi_test_45.xml')
shutil.copy2('./data/faq-docbook51.xml',
'./data/a2x3testdata/faq_ps_test_51.xml')
shutil.copy2('./data/test-docbook51.xml',
'./data/a2x3testdata/tex_test_51.xml')
if os.path.exists(add_dockerpath+'data/a2x3testdata/test.txt'):
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/pdf_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/fop_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/lynx_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/w3m_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/fop_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/epub_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/epub_artifacts_test.txt')
# Test cancelled
# shutil.copy2('data/a2x3testdata/test.txt',
# 'data/a2x3testdata/epubcheck_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/docbook_test.txt')
shutil.copy2(add_dockerpath+'data/a2x3testdata/test.txt',
add_dockerpath+'data/a2x3testdata/chunked_test.txt')
shutil.copy2(add_dockerpath+'data/test-docbook45.xml',
add_dockerpath+'data/a2x3testdata/test-docbook45.xml')
shutil.copy2(add_dockerpath+'data/faq-docbook45.xml',
add_dockerpath+'data/a2x3testdata/faq_dvi_test_45.xml')
shutil.copy2(add_dockerpath+'data/faq-docbook51.xml',
add_dockerpath+'data/a2x3testdata/faq_ps_test_51.xml')
shutil.copy2(add_dockerpath+'data/test-docbook51.xml',
add_dockerpath+'data/a2x3testdata/tex_test_51.xml')
if ARGS.verbose:
print("copy testfiles to ./data/a2x3testdata/")
print("copy testfiles to data/a2x3testdata/")
if not os.path.exists(add_dockerpath+'data/a2x3testdata/images/redsquare'):
os.mkdir(add_dockerpath+'data/a2x3testdata/images/')
shutil.copy2(ad3dir+'images/redsquare.jpg',
add_dockerpath+'data/a2x3testdata/images/redsquare.jpg')
if ARGS.verbose:
print("copy redsquare.jpg to ./data/a2x3testdata/images")
print("")
def run_tests_a2x3(list_data):
"""Runs tests parallel"""
arg_list = ['python3', '../a2x3.py']
"""Run tests parallel"""
arg_list = ['a2x3']
if ARGS.verbose:
arg_list += ['-v']
arg_list += list_data
......@@ -138,12 +129,75 @@ def run_tests_a2x3(list_data):
print(arg_list)
subprocess_a2x3test = subprocess.run(arg_list)
if subprocess_a2x3test.returncode:
print("[WARN] Returncode != zero running", arg_list)
print("[WARNING] Returncode != zero running", arg_list)
if __name__ == '__main__':
"""\
When running inside a container, we need to alter the paths.
"""
add_dockerpath = ''
ad3dir = '../'
if os.path.exists('/.dockerenv'):
path_to_testa2x3_py = os.getcwd()+"/"+__file__
testdir = os.path.dirname(path_to_testa2x3_py)+"/"
add_dockerpath = testdir
ad3dir = testdir[:-6]
if ARGS.verbose:
print("Found '/.dockerenv': working inside a container.")
else:
if ARGS.verbose:
print("No container found.")
TEST_TUPLE = (
# txt to pdf
['-f', 'pdf',
add_dockerpath+'data/a2x3testdata/pdf_test.txt'],
# txt to pdf using fop
['-f', 'pdf', '--fop',
add_dockerpath+'data/a2x3testdata/fop_test.txt'],
# txt to epub
['-f', 'epub',
add_dockerpath+'data/a2x3testdata/epub_test.txt'],
# txt to epub leave artifacts
['-f', 'epub', '-k',
add_dockerpath+'data/a2x3testdata/epub_artifacts_test.txt'],
# txt to epub epubcheck (test cancelled)
# ['-f', 'epub', '-k', '--epubcheck',
# 'data/a2x3testdata/epubcheck_test.txt'],
# txt to text (lynx)
['-f', 'text', '--lynx',
add_dockerpath+'data/a2x3testdata/lynx_test.txt'],
# txt to text (w3m)
['-f', 'text',
add_dockerpath+'data/a2x3testdata/w3m_test.txt'],
# txt to xhtml
['-f', 'xhtml',
add_dockerpath+'data/a2x3testdata/test.txt'],
# txt to manpage
['-f', 'manpage', '-d', 'manpage',
add_dockerpath+'data/a2x3testdata/a2x3.1.txt'],
# txt to docbook xml
['-f', 'docbook',
add_dockerpath+'data/a2x3testdata/docbook_test.txt'],
# xml (docbook) to pdf
['-f', 'pdf',
add_dockerpath+'data/a2x3testdata/test-docbook45.xml'],
# txt to chunked
['-f', 'chunked',
add_dockerpath+'data/a2x3testdata/chunked_test.txt'],
# xml (docbook) to dvi
['-f', 'dvi',
add_dockerpath+'data/a2x3testdata/faq_dvi_test_45.xml'],
# xml (docbook) to ps
['-f', 'ps',
add_dockerpath+'data/a2x3testdata/faq_ps_test_51.xml'],
# xml (docbook) to tex
['-f', 'tex',
add_dockerpath+'data/a2x3testdata/tex_test_51.xml'],
)
remove_testitems()
copy_testfiles()
with futures.ProcessPoolExecutor(max_workers=4) as e:
for test_item in TEST_TUPEL:
with futures.ProcessPoolExecutor(max_workers=3) as e:
for test_item in TEST_TUPLE:
e.submit(run_tests_a2x3, test_item)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment