Пример #1
0
import entire_doc

from test_common import assert_eq, assert_list_eq
import nijiconf

assert_eq([], entire_doc.forge([]))
assert_eq([nijiconf.BR], entire_doc.forge(['']))

assert_list_eq([
    'A' + nijiconf.BR,
    nijiconf.MONO_BLOCK_BEGIN,
    '$ this' + nijiconf.BOLD_BEGIN + 'mono' + nijiconf.BOLD_END + 'line' + nijiconf.BR,
    'another' + nijiconf.BOLD_BEGIN + 'mono' + nijiconf.BOLD_END + 'line' + nijiconf.BR,
    nijiconf.MONO_BLOCK_END,
    nijiconf.TABLE_BEGIN,
    nijiconf.ROW_BEGIN +
        (nijiconf.CELL_BEGIN % ('', ' table')) +
        nijiconf.CELL_END + (nijiconf.CELL_BEGIN % ('', 'in')) +
        nijiconf.CELL_END + nijiconf.ROW_END,
    nijiconf.ROW_BEGIN +
        (nijiconf.CELL_BEGIN % ((nijiconf.CELL_ROW_SPAN % '2'), 'it')) +
        nijiconf.CELL_END + nijiconf.ROW_END,
    nijiconf.TABLE_END,
], entire_doc.forge([
    'A',
    '{{{',
    '$ this**mono**line',
    'another**mono**line',
    '}}}',
    '[[[',
    '|| table||in',
Пример #2
0
import inline

from test_common import assert_eq, assert_ne
from nijiconf import MONO_BEGIN, MONO_END
from nijiconf import BOLD_BEGIN, BOLD_END
from nijiconf import ITALIC_BEGIN, ITALIC_END
from nijiconf import STROKE_BEGIN, STROKE_END
from nijiconf import LINK_BEGIN, LINK_END
from nijiconf import SUP_BEGIN, SUP_END
from nijiconf import SUB_BEGIN, SUB_END
from nijiconf import IMAGE

assert_eq('', inline.forge(''))

text = 'i want a ``**inline** code`` as'
esc_text = ('i want a ' + MONO_BEGIN + BOLD_BEGIN + 'inline' + BOLD_END
          + ' code' + MONO_END + ' as')

text = '@@http://www.google.com/@Google@@'
esc_text = LINK_BEGIN % 'http://www.google.com/' + 'Google' + LINK_END
assert_eq(esc_text, inline.forge(text))

text = '@@http://www.google.com/@Goo@gle@@'
esc_text = LINK_BEGIN % 'http://www.google.com/' + 'Goo@gle' + LINK_END
assert_eq(esc_text, inline.forge(text))

text = '@@http://www.google.com/ @Goo@gle@@'
esc_text = LINK_BEGIN % 'http://www.google.com/ ' + 'Goo@gle' + LINK_END
assert_ne(esc_text, inline.forge(text))

text = '@@http://example.com/#123@Example@@f(x)=a,,1,,^^2^^+a,,0,,'
Пример #3
0
import html

from test_common import assert_eq
import nijiconf

assert_eq('', html.forge(''))

text = ' '
esc_text = nijiconf.AND + 'nbsp;'
assert_eq(esc_text, html.forge(text))

text = '&<>  "'
esc_text = nijiconf.AND + nijiconf.LT + nijiconf.GT + '  ' + nijiconf.DQUOT
assert_eq(esc_text, html.forge(text))

text = '''    "'"'''
esc_text = nijiconf.SPACE * 4 + nijiconf.DQUOT + nijiconf.SQUOT + nijiconf.DQUOT
assert_eq(esc_text, html.forge(text))

text = '''  ...<<... ----'''
esc_text = (nijiconf.SPACE * 2 + '...' + nijiconf.LT * 2 + '...' + ' '
          + nijiconf.MINUS * 3 + '-')
assert_eq(esc_text, html.forge(text))
Пример #4
0
import table

from test_common import assert_eq
import nijiconf
import nijierr

text = '||cell1||cell2||cell3||'
esc_text = ((nijiconf.CELL_BEGIN % ('', 'cell1')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % ('', 'cell2')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % ('', 'cell3')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % ('', '')) + nijiconf.CELL_END)
assert_eq(esc_text, table.row_extract(text))

text = '||cell||;hc;attr-cell'
esc_text = ((nijiconf.CELL_BEGIN % ('', 'cell')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % (nijiconf.CELL_HORI_ALGN
                                  % nijiconf.CELL_HORI_ALIGNMENT_MAP['c']
                                 , 'attr-cell')) + nijiconf.CELL_END)
assert_eq(esc_text, table.row_extract(text))

text = '||n;htr2||no attr cell'
esc_text = ((nijiconf.CELL_BEGIN % ('', 'n;htr2')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % ('', 'no attr cell')) + nijiconf.CELL_END)
assert_eq(esc_text, table.row_extract(text))

text = '|only one||| three lines||;another cell'
esc_text = ('|only one'
          + (nijiconf.CELL_BEGIN % ('', '| three lines')) + nijiconf.CELL_END
          + (nijiconf.CELL_BEGIN % ('', ';another cell')) + nijiconf.CELL_END)
assert_eq(esc_text, table.row_extract(text))