summaryrefslogtreecommitdiff
path: root/tests/test_asciidoc.py
diff options
context:
space:
mode:
authorMatthew Peveler <matt.peveler@gmail.com>2021-10-17 20:39:22 -1000
committerMatthew Peveler <matt.peveler@gmail.com>2021-10-17 21:50:23 -1000
commit7c4d2b9c25a901986412593e9e4e3e1bbbf62b04 (patch)
tree40dfc819c5c68baff2361649ba806a7b61ec1b89 /tests/test_asciidoc.py
parente4b2c71720ceb86d6063613a2903779f6409e24f (diff)
downloadasciidoc-py3-7c4d2b9c25a901986412593e9e4e3e1bbbf62b04.tar.gz
Fix handling escaped attributes inside macrosmpeveler/bugfix-escape-attribute-2
Signed-off-by: Matthew Peveler <matt.peveler@gmail.com>
Diffstat (limited to 'tests/test_asciidoc.py')
-rw-r--r--tests/test_asciidoc.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/test_asciidoc.py b/tests/test_asciidoc.py
new file mode 100644
index 0000000..71d36fe
--- /dev/null
+++ b/tests/test_asciidoc.py
@@ -0,0 +1,65 @@
+from asciidoc import asciidoc
+import io
+import pytest
+
+
+@pytest.mark.parametrize(
+ "input,expected",
+ (
+ (
+ '{attach}file.txt',
+ '<div class="paragraph"><p></p></div>\r\n'
+ ),
+ (
+ '\\{attach}file{0}.txt',
+ '<div class="paragraph"><p></p></div>\r\n'
+ ),
+ (
+ '\\{attach}file.txt',
+ '<div class="paragraph"><p>{attach}file.txt</p></div>\r\n'
+ ),
+ (
+ '\\{0}file.txt',
+ '<div class="paragraph"><p>{0}file.txt</p></div>\r\n'
+ ),
+ (
+ 'link:{attach}file.txt[file]',
+ '<div class="paragraph"><p></p></div>\r\n'
+ ),
+ (
+ 'link:\\{attach}file.txt[file]',
+ '<div class="paragraph"><p>' +
+ '<a href="{attach}file.txt">file</a></p></div>\r\n'
+ ),
+ (
+ 'link:\\{attach}file\\{0}.txt[file\\{bar}too\\{1}]',
+ '<div class="paragraph"><p><a href="{attach}file{0}.txt">' +
+ 'file{bar}too{1}</a></p></div>\r\n'
+ ),
+ (
+ 'image:\\{attach}file.jpg[]',
+ '<div class="paragraph"><p><span class="image">\r\n' +
+ '<img src="{attach}file.jpg" alt="{attach}file.jpg" />\r\n' +
+ '</span></p></div>\r\n'
+ ),
+ (
+ 'image:\\{attach}file.jpg[foo]',
+ '<div class="paragraph"><p><span class="image">\r\n' +
+ '<img src="{attach}file.jpg" alt="foo" />\r\n</span></p></div>\r\n'
+ ),
+ (
+ 'image:\\{attach}file.jpg[\\{bar}?]',
+ '<div class="paragraph"><p><span class="image">\r\n' +
+ '<img src="{attach}file.jpg" alt="{bar}?" />\r\n</span></p></div>\r\n'
+ ),
+ )
+)
+def test_ignore_attribute(input, expected):
+ infile = io.StringIO(input)
+ outfile = io.StringIO()
+ options = [
+ ('--out-file', outfile),
+ ('--no-header-footer', '')
+ ]
+ asciidoc.execute('asciidoc', options, [infile])
+ assert outfile.getvalue() == expected