diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..62104894 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,27 @@ +--- +name: Bug report +about: Report a parsing error, unexpected output and other bugs +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Attach a minimal markdown snippet that causes the bug to occur. This should be placed inside a fenced code block to escape GitHub's formatting. + +If your snippet contains fenced code blocks then you can escape them by adding more backticks to the enclosing block. See the [this GitHub article](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#fenced-code-blocks) for an example. + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Debug info** +Version of library being used: + +Any extras being used: + +**Additional context** +Add any other context about the problem here. diff --git a/.github/workflows/python.yaml b/.github/workflows/python.yaml new file mode 100644 index 00000000..e642ccdd --- /dev/null +++ b/.github/workflows/python.yaml @@ -0,0 +1,32 @@ +name: PythonCI +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] + os: + - ubuntu-latest + - macos-latest + - windows-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install .[all] + - name: Test + run: | + make testone + - name: Test ReDoS + run: | + make testredos diff --git a/.gitignore b/.gitignore index 722351f9..0b671943 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ sandbox/*.html __pycache__ .tox *.egg-info +*.idea +venv \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 93208f8f..00000000 --- a/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: python -python: - - "2.7" - - "pypy" - - "3.4" - - "3.5" - - "3.6" - - "3.7-dev" -# command to install dependencies -install: pip install Pygments>=2.1.1 -# command to run tests -script: make testone diff --git a/CHANGES.md b/CHANGES.md index 9b27c624..60c03486 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,217 @@ # python-markdown2 Changelog -## python-markdown2 2.3.9 (not yet released) +## python-markdown2 2.5.5 (not yet released) -(nothing yet) +- [pull #639] Fix middle-word-em interfering with strongs (#637) +- [pull #640] Fix code friendly extra stopping other syntax being processed (#638) +- [pull #644] Fix a number of em/strong issues (#641, #642, #643) + + +## python-markdown2 2.5.4 + +- [pull #617] Add MarkdownFileLinks extra (#528) +- [pull #622] Add missing block tags to regex (#620) +- [pull #623] Don't escape plus signs in URLs (#621) +- [pull #626] Fix XSS when encoding incomplete tags (#625) +- [pull #628] Fix TypeError in MiddleWordEm extra when options was None (#627) +- [pull #630] Fix nbsp breaking tables (#629) +- [pull #634] Fix ReDoS in HTML tokenizer regex (#633) + + +## python-markdown2 2.5.3 + +- [pull #616] make tables without body gfm compatible + + +## python-markdown2 2.5.2 + +- [pull #605] Add support for Python 3.13, drop EOL 3.8 +- [pull #607] Fix `middle-word-em` extra preventing strongs from being recognized (#606) +- [pull #609] Add option to output to file in CLI (#608) +- [pull #612] Fix footnote labels appearing out-of-order (#536) +- [pull #613] Fix smarty pants extra not triggering when it should (#611) + + +## python-markdown2 2.5.1 + +- [pull #590] Fix underscores within bold text getting emphasized (#589) +- [pull #591] Add Alerts extra +- [pull #595] Fix img alt text being processed as markdown (#594) +- [pull #598] Add `link-shortrefs` extra (#597) +- [pull #600] Use urandom for SECRET_SALT +- [pull #602] Fix XSS issue in safe mode (#601) +- [pull #604] Fix XSS injection in image URLs (#603) + + +## python-markdown2 2.5.0 + +- [pull #519] Add support for custom extras +- [pull #519] Drop Python 3.5 support +- [pull #568] Add `prepend` arg to toc extra (#397) +- [pull #569] Process HTML comments as markdown in 'escape' safe mode +- [pull #570] Fix syntax warnings in test suite +- [pull #572] Process inline tags as HTML blocks when they span multiple lines (#571) +- [pull #573] Add new LaTeX Extra +- [pull #576] Fix `html`, `head` and `body` tags being wrapped in `

` tags (#575) +- [pull #578] Graceful handling of broken lists when cuddled-lists extra is enabled +- [pull #581] Add type hints (#562) +- [pull #581] Drop Python 3.6 and 3.7 support +- [pull #582] Fix fenced code blocks breaking lists (#580) +- [pull #586] Fix #583 by tweaking incomplete tag regex +- [pull #587] Fix AssertionError on malformed HTML (#584) + + +## python-markdown2 2.4.13 + +- [pull #559] Allow cuddled tables (#557) +- [pull #560] Fix `markdown-in-html` not always splitting HTML tags into separate lines (#558) +- [pull #564] Fix incomplete comments in safe mode not being escaped (#563) +- [pull #566] Fix crash in `markdown-in-html` extra (#565) + + +## python-markdown2 2.4.12 + +- [pull #547] Update `markdown-in-html` extra to handle markdown on same line as HTML (#546) +- [pull #550] Fix tables with trailing whitespace not being recognized (#549) +- [pull #545] Fix multiple instances of strong emphasis (`**`) in one line (#541) +- [pull #556] Fix incorrect parsing of links after square brackets (#552) + +## python-markdown2 2.4.11 + +- [pull #524] Fix angles being escaped in style blocks (issue #523) +- [pull #527] Fix base64 images being corrupted in safe mode (issue #526) +- [pull #529] Add `breaks` extra with ability to hard break on backslashes (issue #525) +- [pull #532] Fix #493 persisting when `code-friendly` extra enabled +- [pull #535] Update `_slugify` to use utf-8 encoding (issue #534) +- [pull #536] Maintain order of appearance in footnotes +- [pull #538] Include HTML headers in TOC +- [pull #540] Add mechanism to prevent header ID counter resetting (issue #530) + +## python-markdown2 2.4.10 + +- [pull #520] Allow more relative links in safe mode (issue #517) +- [pull #521] Always restore hashed HTML blocks (issue #185) +- [pull #522] Add `middle-word-em` extra + + +## python-markdown2 2.4.9 + +- [pull #500] Add `` tag to html-classes extra +- [pull #501] Fix link patterns extra matching against internal hashes +- [pull #502] Replace deprecated `optparse` with `argparse` +- [pull #506] Fix `_uniform_outdent` failing with empty strings (issue #505) +- [pull #509] Fix HTML elements not unhashing correctly (issue 508) +- [pull #511] Remove deprecated `imp` module (issue #510) +- [pull #512] Allow link patterns to be passed via extras dict +- [pull #513] Fix relative links not working in safe mode (issue #254) + + +## python-markdown2 2.4.8 + +- [pull #499] Fix images not being procesed correctly (#498) + + +## python-markdown2 2.4.7 + +- [pull #483] Fix hashing nested HTML blocks +- [pull #486] Fix backslash being unable to escape raw HTML tags +- [pull #482] Add support for telegram spoiler in extras +- [pull #485] mermaid support +- [pull #487] Fix escaping ampersands in hrefs +- [pull #490] Fix indented codeblocks inside fences (#489) +- [pull #490] Remove `code-color` extra + + +## python-markdown2 2.4.6 + +- [pull #477] Feature wavedrom support +- [pull #480] Fix mixing ordered and un-ordered lists combining into single list type + + +## python-markdown2 2.4.5 + +- [pull #466] Add optional dependencies to `setup.py` + + +## python-markdown2 2.4.4 + +- [pull #439] Fix TypeError if html-classes extra is None +- [pull #441] Remove Python2 support +- [pull #445] Replace `` with `` in strike extra +- [pull #446] Fix link patterns extra applying within links +- [pull #443] create proper entry point +- [pull #449] Codespans inside link text issue344 +- [pull #451] Underline and HTML comments +- [pull #453] Links with brackets +- [pull #454] Fix emacs local variable one-liners +- [pull #457] Example of the current mixed-paragraph mode behavior in lists +- [pull #455] Fix code block indentation in lists +- [pull #434] Fix filter bypass leading to XSS (#362) +- [pull #464] Fix html-classes extra not applying to code spans +- [pull #462] Fix pygments block matching +- [pull #462] Fix pyshell blocks in blockquotes +- [pull #463] Fix multilevel lists +- [pull #468] Remove `_uniform_outdent_limit` function +- [pull #470] Add support for ordered lists that don't start at 1. (#469) +- [pull #472] Fix `AssertionError` with lazy numbered lists (issue #471) +- [pull #475] Add `

" % indent()) + return '\n'.join(lines) + '\n' + + +class UnicodeWithAttrs(str): + """A subclass of unicode used for the return value of conversion to + possibly attach some attributes. E.g. the "toc_html" attribute when + the "toc" extra is used. + """ + metadata: Optional[dict[str, str]] = None + toc_html: Optional[str] = None + +## {{{ http://code.activestate.com/recipes/577257/ (r1) +_slugify_strip_re = re.compile(r'[^\w\s-]') +_slugify_hyphenate_re = re.compile(r'[-\s]+') +def _slugify(value: str) -> str: + """ + Normalizes string, converts to lowercase, removes non-alpha characters, + and converts spaces to hyphens. From Django's "django/template/defaultfilters.py". """ import unicodedata - value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode() + value = unicodedata.normalize('NFKD', value).encode('utf-8', 'ignore').decode() value = _slugify_strip_re.sub('', value).strip().lower() return _slugify_hyphenate_re.sub('-', value) ## end of http://code.activestate.com/recipes/577257/ }}} # From http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52549 -def _curry(*args, **kwargs): - function, args = args[0], args[1:] +def _curry(function: Callable, *args, **kwargs) -> Callable: def result(*rest, **kwrest): combined = kwargs.copy() combined.update(kwrest) @@ -2335,7 +3910,7 @@ def result(*rest, **kwrest): # Recipe: regex_from_encoded_pattern (1.0) -def _regex_from_encoded_pattern(s): +def _regex_from_encoded_pattern(s: str) -> re.Pattern: """'foo' -> re.compile(re.escape('foo')) '/foo/' -> re.compile('foo') '/foo/i' -> re.compile('foo', re.I) @@ -2343,7 +3918,7 @@ def _regex_from_encoded_pattern(s): if s.startswith('/') and s.rfind('/') != 0: # Parse it: /PATTERN/FLAGS idx = s.rfind('/') - pattern, flags_str = s[1:idx], s[idx+1:] + _, flags_str = s[1:idx], s[idx+1:] flag_from_char = { "i": re.IGNORECASE, "l": re.LOCALE, @@ -2365,7 +3940,7 @@ def _regex_from_encoded_pattern(s): # Recipe: dedent (0.1.2) -def _dedentlines(lines, tabsize=8, skip_first_line=False): +def _dedentlines(lines: list[str], tabsize: int = 8, skip_first_line: bool = False) -> list[str]: """_dedentlines(lines, tabsize=8, skip_first_line=False) -> dedented lines "lines" is a list of lines to dedent. @@ -2383,7 +3958,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): % (tabsize, skip_first_line)) margin = None for i, line in enumerate(lines): - if i == 0 and skip_first_line: continue + if i == 0 and skip_first_line: + continue indent = 0 for ch in line: if ch == ' ': @@ -2396,16 +3972,19 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): break else: continue # skip all-whitespace lines - if DEBUG: print("dedent: indent=%d: %r" % (indent, line)) + if DEBUG: + print("dedent: indent=%d: %r" % (indent, line)) if margin is None: margin = indent else: margin = min(margin, indent) - if DEBUG: print("dedent: margin=%r" % margin) + if DEBUG: + print("dedent: margin=%r" % margin) if margin is not None and margin > 0: for i, line in enumerate(lines): - if i == 0 and skip_first_line: continue + if i == 0 and skip_first_line: + continue removed = 0 for j, ch in enumerate(line): if ch == ' ': @@ -2413,7 +3992,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): elif ch == '\t': removed += tabsize - (removed % tabsize) elif ch in '\r\n': - if DEBUG: print("dedent: %r: EOL -> strip up to EOL" % line) + if DEBUG: + print("dedent: %r: EOL -> strip up to EOL" % line) lines[i] = lines[i][j:] break else: @@ -2435,7 +4015,7 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): return lines -def _dedent(text, tabsize=8, skip_first_line=False): +def _dedent(text: str, tabsize: int = 8, skip_first_line: bool = False) -> str: """_dedent(text, tabsize=8, skip_first_line=False) -> dedented text "text" is the text to dedent. @@ -2446,12 +4026,12 @@ def _dedent(text, tabsize=8, skip_first_line=False): textwrap.dedent(s), but don't expand tabs to spaces """ - lines = text.splitlines(1) + lines = text.splitlines(True) _dedentlines(lines, tabsize=tabsize, skip_first_line=skip_first_line) return ''.join(lines) -class _memoized(object): +class _memoized: """Decorator that caches a function's return value each time it is called. If called later with the same arguments, the cached value is returned, and not re-evaluated. @@ -2478,7 +4058,7 @@ def __repr__(self): return self.func.__doc__ -def _xml_oneliner_re_from_tab_width(tab_width): +def _xml_oneliner_re_from_tab_width(tab_width: int) -> re.Pattern: """Standalone XML processing instruction regex.""" return re.compile(r""" (?: @@ -2500,7 +4080,7 @@ def _xml_oneliner_re_from_tab_width(tab_width): _xml_oneliner_re_from_tab_width = _memoized(_xml_oneliner_re_from_tab_width) -def _hr_tag_re_from_tab_width(tab_width): +def _hr_tag_re_from_tab_width(tab_width: int) -> re.Pattern: return re.compile(r""" (?: (?<=\n\n) # Starting after a blank line @@ -2520,7 +4100,7 @@ def _hr_tag_re_from_tab_width(tab_width): _hr_tag_re_from_tab_width = _memoized(_hr_tag_re_from_tab_width) -def _xml_escape_attr(attr, skip_single_quote=True): +def _xml_escape_attr(attr: str, skip_single_quote: bool = True) -> str: """Escape the given string for use in an HTML/XML tag attribute. By default this doesn't bother with escaping `'` to `'`, presuming that @@ -2537,7 +4117,7 @@ def _xml_escape_attr(attr, skip_single_quote=True): return escaped -def _xml_encode_email_char_at_random(ch): +def _xml_encode_email_char_at_random(ch: str) -> str: r = random() # Roughly 10% raw, 45% hex, 45% dec. # '@' *must* be encoded. I [John Gruber] insist. @@ -2551,22 +4131,31 @@ def _xml_encode_email_char_at_random(ch): return '&#%s;' % ord(ch) -def _html_escape_url(https://github.com/attr,%20safe_mode=False): - """Replace special characters that are potentially malicious in url string.""" +def _html_escape_url( + attr: str, + safe_mode: Union[_safe_mode, bool, None] = False, + charset: Optional[str] = None +): + """ + Replace special characters that are potentially malicious in url string. + + Args: + charset: don't escape characters from this charset. Currently the only + exception is for '+' when charset=='base64' + """ escaped = (attr .replace('"', '"') .replace('<', '<') .replace('>', '>')) if safe_mode: - escaped = escaped.replace('+', ' ') escaped = escaped.replace("'", "'") return escaped # ---- mainline -class _NoReflowFormatter(optparse.IndentedHelpFormatter): - """An optparse formatter that does NOT reflow the description.""" +class _NoReflowFormatter(argparse.RawDescriptionHelpFormatter): + """An argparse formatter that does NOT reflow the description.""" def format_description(self, description): return description or "" @@ -2582,38 +4171,46 @@ def main(argv=None): if not logging.root.handlers: logging.basicConfig() - usage = "usage: %prog [PATHS...]" - version = "%prog "+__version__ - parser = optparse.OptionParser(prog="markdown2", usage=usage, - version=version, description=cmdln_desc, - formatter=_NoReflowFormatter()) - parser.add_option("-v", "--verbose", dest="log_level", + parser = argparse.ArgumentParser( + prog="markdown2", description=cmdln_desc, usage='%(prog)s [PATHS...]', + formatter_class=_NoReflowFormatter + ) + parser.add_argument('--version', action='https://github.com/version', + version=f'%(prog)s {__version__}') + parser.add_argument('paths', nargs='*', + help=( + 'optional list of files to convert.' + 'If none are given, stdin will be used' + )) + parser.add_argument("-v", "--verbose", dest="log_level", action="https://github.com/store_const", const=logging.DEBUG, help="more verbose output") - parser.add_option("--encoding", + parser.add_argument("--encoding", help="specify encoding of text content") - parser.add_option("--html4tags", action="https://github.com/store_true", default=False, + parser.add_argument("--html4tags", action="https://github.com/store_true", default=False, help="use HTML 4 style for empty element tags") - parser.add_option("-s", "--safe", metavar="MODE", dest="safe_mode", + parser.add_argument("-s", "--safe", metavar="MODE", dest="safe_mode", help="sanitize literal HTML: 'escape' escapes " "HTML meta chars, 'replace' replaces with an " "[HTML_REMOVED] note") - parser.add_option("-x", "--extras", action="https://github.com/append", + parser.add_argument("-x", "--extras", action="https://github.com/append", help="Turn on specific extra features (not part of " "the core Markdown spec). See above.") - parser.add_option("--use-file-vars", + parser.add_argument("--use-file-vars", help="Look for and use Emacs-style 'markdown-extras' " "file var to turn on extras. See " "") - parser.add_option("--link-patterns-file", + parser.add_argument("--link-patterns-file", help="path to a link pattern file") - parser.add_option("--self-test", action="https://github.com/store_true", + parser.add_argument("--self-test", action="https://github.com/store_true", help="run internal self-tests (some doctests)") - parser.add_option("--compare", action="https://github.com/store_true", + parser.add_argument("--compare", action="https://github.com/store_true", help="run against Markdown.pl as well (for testing)") + parser.add_argument('--output', type=str, help='output to a file instead of stdout') parser.set_defaults(log_level=logging.INFO, compare=False, encoding="utf-8", safe_mode=None, use_file_vars=False) - opts, paths = parser.parse_args() + opts = parser.parse_args() + paths = opts.paths log.setLevel(opts.log_level) if opts.self_test: @@ -2641,8 +4238,10 @@ def main(argv=None): f = open(opts.link_patterns_file) try: for i, line in enumerate(f.readlines()): - if not line.strip(): continue - if line.lstrip().startswith("#"): continue + if not line.strip(): + continue + if line.lstrip().startswith("#"): + continue try: pat, href = line.rstrip().rsplit(None, 1) except ValueError: @@ -2655,7 +4254,7 @@ def main(argv=None): else: link_patterns = None - from os.path import join, dirname, abspath, exists + from os.path import abspath, dirname, exists, join markdown_pl = join(dirname(dirname(abspath(__file__))), "test", "Markdown.pl") if not paths: @@ -2668,17 +4267,13 @@ def main(argv=None): text = fp.read() fp.close() if opts.compare: - from subprocess import Popen, PIPE + from subprocess import PIPE, Popen print("==== Markdown.pl ====") p = Popen('perl %s' % markdown_pl, shell=True, stdin=PIPE, stdout=PIPE, close_fds=True) p.stdin.write(text.encode('utf-8')) p.stdin.close() perl_html = p.stdout.read().decode('utf-8') - if py3: - sys.stdout.write(perl_html) - else: - sys.stdout.write(perl_html.encode( - sys.stdout.encoding or "utf-8", 'xmlcharrefreplace')) + sys.stdout.write(perl_html) print("==== markdown2.py ====") html = markdown(text, html4tags=opts.html4tags, @@ -2686,11 +4281,11 @@ def main(argv=None): extras=extras, link_patterns=link_patterns, use_file_vars=opts.use_file_vars, cli=True) - if py3: - sys.stdout.write(html) + if opts.output: + with open(opts.output, 'w') as f: + f.write(html) else: - sys.stdout.write(html.encode( - sys.stdout.encoding or "utf-8", 'xmlcharrefreplace')) + sys.stdout.write(html) if extras and "toc" in extras: log.debug("toc_html: " + str(html.toc_html.encode(sys.stdout.encoding or "utf-8", 'xmlcharrefreplace'))) diff --git a/perf/gen_perf_cases.py b/perf/gen_perf_cases.py index ecd4c54e..8a45f3e4 100755 --- a/perf/gen_perf_cases.py +++ b/perf/gen_perf_cases.py @@ -4,7 +4,6 @@ from os.path import * import sys import re -import datetime from glob import glob import operator import shutil @@ -16,7 +15,7 @@ def gen_aspn_cases(limit=0): base_dir = TMP+'aspn-cases' if exists(base_dir): - print "'%s' exists, skipping" % base_dir + print("'%s' exists, skipping" % base_dir) return os.makedirs(base_dir) sys.stdout.write("generate %s" % base_dir); sys.stdout.flush() @@ -49,10 +48,10 @@ def gen_aspn_cases(limit=0): def gen_test_cases(): base_dir = TMP+"test-cases" if exists(base_dir): - print "'%s' exists, skipping" % base_dir + print("'%s' exists, skipping" % base_dir) return os.makedirs(base_dir) - print "generate %s" % base_dir + print("generate %s" % base_dir) for test_cases_dir in glob(join("..", "test", "*-cases")): for text_file in glob(join(test_cases_dir, "*.text")): shutil.copy(text_file, join(base_dir, basename(text_file))) @@ -70,8 +69,6 @@ def gen_test_cases(): i_pat = re.compile(r"<(i)>(.*?)", re.I) def _markdown_from_aspn_html(html): - from cgi import escape - markdown = html markdown = br_eol_pat.sub('\n', markdown) #
EOL @@ -107,9 +104,9 @@ def _markdown_from_aspn_html(html): title = None escaped_href = href.replace('(', '\\(').replace(')', '\\)') if title is None: - replacement = '[%s](%s)' % (content, escaped_href) + replacement = '[{}]({})'.format(content, escaped_href) else: - replacement = '[%s](%s "%s")' % (content, escaped_href, + replacement = '[{}]({} "{}")'.format(content, escaped_href, title.replace('"', "'")) markdown = markdown[:start] + replacement + markdown[end:] @@ -137,7 +134,7 @@ def _markdown_from_aspn_html(html): try: idx = markdown.index(marker) except ValueError: - print "marker: %r" % marker + print("marker: %r" % marker) raise if not markdown[:idx].strip(): #TODO: Correct this false diagnosis. Problem is not limited @@ -194,8 +191,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): """ DEBUG = False if DEBUG: - print "dedent: dedent(..., tabsize=%d, skip_first_line=%r)"\ - % (tabsize, skip_first_line) + print("dedent: dedent(..., tabsize=%d, skip_first_line=%r)"\ + % (tabsize, skip_first_line)) indents = [] margin = None for i, line in enumerate(lines): @@ -212,12 +209,12 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): break else: continue # skip all-whitespace lines - if DEBUG: print "dedent: indent=%d: %r" % (indent, line) + if DEBUG: print("dedent: indent=%d: %r" % (indent, line)) if margin is None: margin = indent else: margin = min(margin, indent) - if DEBUG: print "dedent: margin=%r" % margin + if DEBUG: print("dedent: margin=%r" % margin) if margin is not None and margin > 0: for i, line in enumerate(lines): @@ -229,7 +226,7 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): elif ch == '\t': removed += tabsize - (removed % tabsize) elif ch in '\r\n': - if DEBUG: print "dedent: %r: EOL -> strip up to EOL" % line + if DEBUG: print("dedent: %r: EOL -> strip up to EOL" % line) lines[i] = lines[i][j:] break else: @@ -237,8 +234,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False): "line %r while removing %d-space margin" % (ch, line, margin)) if DEBUG: - print "dedent: %r: %r -> removed %d/%d"\ - % (line, ch, removed, margin) + print("dedent: %r: %r -> removed %d/%d"\ + % (line, ch, removed, margin)) if removed == margin: lines[i] = lines[i][j+1:] break diff --git a/perf/perf.py b/perf/perf.py index ea6f10ea..ed8bd864 100755 --- a/perf/perf.py +++ b/perf/perf.py @@ -10,7 +10,6 @@ import os import sys -import timeit import time from os.path import * from glob import glob @@ -35,7 +34,7 @@ def time_markdown_py(cases_dir, repeat): for i in range(repeat): start = clock() for path in glob(join(cases_dir, "*.text")): - f = open(path, 'r') + f = open(path) content = f.read() f.close() try: @@ -45,7 +44,7 @@ def time_markdown_py(cases_dir, repeat): pass end = clock() times.append(end - start) - print " markdown.py: best of %d: %.3fs" % (repeat, min(times)) + print(" markdown.py: best of %d: %.3fs" % (repeat, min(times))) @hotshotit def hotshot_markdown2_py(cases_dir, repeat): @@ -60,13 +59,13 @@ def time_markdown2_py(cases_dir, repeat): for i in range(repeat): start = clock() for path in glob(join(cases_dir, "*.text")): - f = open(path, 'r') + f = open(path) content = f.read() f.close() markdowner.convert(content) end = clock() times.append(end - start) - print " markdown2.py: best of %d: %.3fs" % (repeat, min(times)) + print(" markdown2.py: best of %d: %.3fs" % (repeat, min(times))) def time_markdown_pl(cases_dir, repeat): times = [] @@ -75,7 +74,7 @@ def time_markdown_pl(cases_dir, repeat): os.system('perl time_markdown_pl.pl "%s"' % cases_dir) end = clock() times.append(end - start) - print " Markdown.pl: best of %d: %.3fs" % (repeat, min(times)) + print(" Markdown.pl: best of %d: %.3fs" % (repeat, min(times))) def time_all(cases_dir, repeat): time_markdown_pl(cases_dir, repeat=repeat) @@ -131,10 +130,10 @@ def main(args=sys.argv): if timer_name not in d: raise ValueError("no '%s' timer function" % timer_name) timer = d[timer_name] - print "Profile conversion of %s (plat=%s):" \ - % (os.path.join(cases_dir, "*.text"), sys.platform) + print("Profile conversion of %s (plat=%s):" \ + % (os.path.join(cases_dir, "*.text"), sys.platform)) timer(cases_dir, repeat=opts.repeat) - print + print() os.system("python show_stats.py %s.prof" % timer_name) else: @@ -145,8 +144,8 @@ def main(args=sys.argv): if timer_name not in d: raise ValueError("no '%s' timer function" % timer_name) timer = d[timer_name] - print "Time conversion of %s (plat=%s):" \ - % (os.path.join(cases_dir, "*.text"), sys.platform) + print("Time conversion of %s (plat=%s):" \ + % (os.path.join(cases_dir, "*.text"), sys.platform)) timer(cases_dir, repeat=opts.repeat) if __name__ == "__main__": diff --git a/perf/strip_cookbook_data.py b/perf/strip_cookbook_data.py index 0f4abed0..d92597b8 100644 --- a/perf/strip_cookbook_data.py +++ b/perf/strip_cookbook_data.py @@ -1,7 +1,5 @@ - from os.path import * -from pprint import pprint, pformat -import datetime +from pprint import pformat def doit(): recipes_path = expanduser("recipes.pprint") @@ -14,11 +12,10 @@ def doit(): for key in c.keys(): if key not in ('comment', 'title'): del c[key] - + f = open("stripped.pprint", 'w') f.write(pformat(recipe_dicts)) f.close() doit() - diff --git a/perf/util.py b/perf/util.py index 05a22a0c..7fcc862f 100644 --- a/perf/util.py +++ b/perf/util.py @@ -3,15 +3,7 @@ """Perf utility functions""" -import os -from os.path import basename import sys -import md5 -import re -import stat -import textwrap -import types -from pprint import pprint, pformat # Global dict for holding specific hotshot profilers @@ -38,14 +30,14 @@ def wrapper(*args, **kw): return func(*args, **kw) finally: total_time = clock() - start_time - print "%s took %.3fs" % (func.func_name, total_time) + print("{} took {:.3f}s".format(func.__name__, total_time)) return wrapper def hotshotit(func): def wrapper(*args, **kw): import hotshot global hotshotProfilers - prof_name = func.func_name+".prof" + prof_name = func.__name__+".prof" profiler = hotshotProfilers.get(prof_name) if profiler is None: profiler = hotshot.Profile(prof_name) diff --git a/sandbox/wiki.py b/sandbox/wiki.py index ac27199a..fbe0894a 100644 --- a/sandbox/wiki.py +++ b/sandbox/wiki.py @@ -1,4 +1,3 @@ - import sys import re from os.path import * @@ -18,4 +17,4 @@ ] processor = markdown2.Markdown(extras=["link-patterns"], link_patterns=link_patterns) -print processor.convert(wiki_page) +print(processor.convert(wiki_page)) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 5e409001..00000000 --- a/setup.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[wheel] -universal = 1 diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index 1d374829..14cd4564 --- a/setup.py +++ b/setup.py @@ -17,15 +17,12 @@ Intended Audience :: Developers License :: OSI Approved :: MIT License Programming Language :: Python -Programming Language :: Python :: 2 -Programming Language :: Python :: 2.6 -Programming Language :: Python :: 2.7 Programming Language :: Python :: 3 -Programming Language :: Python :: 3.3 -Programming Language :: Python :: 3.4 -Programming Language :: Python :: 3.5 -Programming Language :: Python :: 3.6 -Programming Language :: Python :: 3.7 +Programming Language :: Python :: 3.9 +Programming Language :: Python :: 3.10 +Programming Language :: Python :: 3.11 +Programming Language :: Python :: 3.12 +Programming Language :: Python :: 3.13 Operating System :: OS Independent Topic :: Software Development :: Libraries :: Python Modules Topic :: Software Development :: Documentation @@ -33,7 +30,13 @@ Topic :: Text Processing :: Markup :: HTML """ -script = (sys.platform == "win32" and "lib\\markdown2.py" or "bin/markdown2") +extras_require = { + "code_syntax_highlighting": ["pygments>=2.7.3"], + "wavedrom": ["wavedrom"], + "latex": ['latex2mathml; python_version>="3.8.1"'], +} +# nested listcomp to combine all optional extras into convenient "all" option +extras_require["all"] = [i for v in tuple(extras_require.values()) for i in v] setup( name="markdown2", @@ -47,9 +50,15 @@ platforms=["any"], py_modules=["markdown2"], package_dir={"": "lib"}, - scripts=[script], + entry_points={ + "console_scripts": [ + "markdown2 = markdown2:main" + ] + }, description="A fast and complete Python implementation of Markdown", - classifiers=filter(None, classifiers.split("\n")), + python_requires=">=3.9, <4", + extras_require=extras_require, + classifiers=classifiers.strip().split("\n"), long_description="""markdown2: A fast and complete Python implementation of Markdown. Markdown is a text-to-HTML filter; it translates an easy-to-read / diff --git a/test/markdown.py b/test/markdown.py index 07334a81..b2ef85da 100644 --- a/test/markdown.py +++ b/test/markdown.py @@ -29,16 +29,16 @@ """ -import re, sys, os, random, codecs +import re, sys, codecs # Set debug level: 3 none, 2 critical, 1 informative, 0 all -(VERBOSE, INFO, CRITICAL, NONE) = range(4) +(VERBOSE, INFO, CRITICAL, NONE) = list(range(4)) MESSAGE_THRESHOLD = CRITICAL def message(level, text) : if level >= MESSAGE_THRESHOLD : - print text + print(text) # --------------- CONSTANTS YOU MIGHT WANT TO MODIFY ----------------- @@ -48,9 +48,9 @@ def message(level, text) : SMART_EMPHASIS = 1 # this_or_that does not become thisorthat HTML_REMOVED_TEXT = "[HTML_REMOVED]" # text used instead of HTML in safe mode -RTL_BIDI_RANGES = ( (u'\u0590', u'\u07FF'), +RTL_BIDI_RANGES = ( ('\u0590', '\u07FF'), # from Hebrew to Nko (includes Arabic, Syriac and Thaana) - (u'\u2D30', u'\u2D7F'), + ('\u2D30', '\u2D7F'), # Tifinagh ) @@ -62,9 +62,9 @@ def message(level, text) : # 0780-07BF - Thaana # 07C0-07FF - Nko -BOMS = { 'utf-8' : (unicode(codecs.BOM_UTF8, "utf-8"), ), - 'utf-16' : (unicode(codecs.BOM_UTF16_LE, "utf-16"), - unicode(codecs.BOM_UTF16_BE, "utf-16")), +BOMS = { 'utf-8' : (str(codecs.BOM_UTF8, "utf-8"), ), + 'utf-16' : (str(codecs.BOM_UTF16_LE, "utf-16"), + str(codecs.BOM_UTF16_BE, "utf-16")), #'utf-32' : (unicode(codecs.BOM_UTF32_LE, "utf-32"), # unicode(codecs.BOM_UTF32_BE, "utf-32")), } @@ -116,7 +116,7 @@ def is_block_level (tag) : (re.compile(">"), ">"), (re.compile("\""), """)] -ENTITY_NORMALIZATION_EXPRESSIONS_SOFT = [ (re.compile("&(?!\#)"), "&"), +ENTITY_NORMALIZATION_EXPRESSIONS_SOFT = [ (re.compile(r"&(?!\#)"), "&"), (re.compile("<"), "<"), (re.compile(">"), ">"), (re.compile("\""), """)] @@ -128,7 +128,7 @@ def getBidiType(text) : ch = text[0] - if not isinstance(ch, unicode) or not ch.isalpha(): + if not isinstance(ch, str) or not ch.isalpha(): return None else : @@ -312,7 +312,7 @@ def toxml(self): if self.nodeName in ['p', 'li', 'ul', 'ol', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'] : - if not self.attribute_values.has_key("dir"): + if "dir" not in self.attribute_values: if self.bidi : bidi = self.bidi else : @@ -325,7 +325,7 @@ def toxml(self): value = self.attribute_values[attr] value = self.doc.normalizeEntities(value, avoidDoubleNormalizing=True) - buffer += ' %s="%s"' % (attr, value) + buffer += ' {}="{}"'.format(attr, value) # Now let's actually append the children @@ -672,7 +672,7 @@ def run (self, lines) : LINK_ANGLED_RE = BRK + r'\s*\(<([^\)]*)>\)' # [text]() IMAGE_LINK_RE = r'\!' + BRK + r'\s*\(([^\)]*)\)' # ![alttxt](http://x.com/) REFERENCE_RE = BRK+ r'\s*\[([^\]]*)\]' # [Google][3] -IMAGE_REFERENCE_RE = r'\!' + BRK + '\s*\[([^\]]*)\]' # ![alt text][2] +IMAGE_REFERENCE_RE = r'\!' + BRK + r'\s*\[([^\]]*)\]' # ![alt text][2] NOT_STRONG_RE = r'( \* )' # stand-alone * or _ AUTOLINK_RE = r'<(http://[^>]*)>' # AUTOMAIL_RE = r'<([^> \!]*@[^> ]*)>' # @@ -788,7 +788,7 @@ def handleMatch(self, m, doc): # we'll use "google" as the id id = m.group(2).lower() - if not self.references.has_key(id) : # ignore undefined refs + if id not in self.references : # ignore undefined refs return None href, title = self.references[id] text = m.group(2) @@ -1127,7 +1127,7 @@ def registerExtensions(self, extensions, configs) : % (ext, extension_module_name) ) else : - if configs.has_key(ext) : + if ext in configs : configs_for_ext = configs[ext] else : configs_for_ext = [] @@ -1489,7 +1489,7 @@ def _handleInlineWrapper (self, line) : x = parts[i] - if isinstance(x, (str, unicode)) : + if isinstance(x, str) : result = self._applyPattern(x, pattern) if result : @@ -1502,7 +1502,7 @@ def _handleInlineWrapper (self, line) : for i in range(len(parts)) : x = parts[i] - if isinstance(x, (str, unicode)) : + if isinstance(x, str) : parts[i] = self.doc.createTextNode(x) return parts @@ -1577,7 +1577,7 @@ def _applyPattern(self, line, pattern) : for item in result: - if isinstance(item, (str, unicode)): + if isinstance(item, str): if len(item) > 0: node.insertChild(position, self.doc.createTextNode(item)) @@ -1723,7 +1723,7 @@ def __init__(self, configs = {}) : self.config = configs def getConfig(self, key) : - if self.config.has_key(key) : + if key in self.config : return self.config[key][0] else : return "" @@ -1757,7 +1757,7 @@ def parse_options() : 'encoding' : None } else : - print OPTPARSE_WARNING + print(OPTPARSE_WARNING) return None parser = optparse.OptionParser(usage="%prog INPUTFILE [options]") diff --git a/test/markdowntest-cases/Auto links.html b/test/markdowntest-cases/Auto links.html index f8df9852..f13817fd 100644 --- a/test/markdowntest-cases/Auto links.html +++ b/test/markdowntest-cases/Auto links.html @@ -1,6 +1,6 @@

Link: http://example.com/.

-

With an ampersand: http://example.com/?foo=1&bar=2

+

With an ampersand: http://example.com/?foo=1&bar=2

  • In a list?
  • diff --git a/test/markdowntest-cases/Strong and em together.html b/test/markdowntest-cases/Strong and em together.html index 71ec78c7..bab1b98f 100644 --- a/test/markdowntest-cases/Strong and em together.html +++ b/test/markdowntest-cases/Strong and em together.html @@ -1,7 +1,7 @@ -

    This is strong and em.

    +

    This is strong and em.

    -

    So is this word.

    +

    So is this word.

    -

    This is strong and em.

    +

    This is strong and em.

    -

    So is this word.

    +

    So is this word.

    diff --git a/test/php-markdown-cases/Links, inline style.html b/test/php-markdown-cases/Links, inline style.html index d3e4d111..98e7da52 100644 --- a/test/php-markdown-cases/Links, inline style.html +++ b/test/php-markdown-cases/Links, inline style.html @@ -1 +1 @@ -

    silly URL w/ angle brackets.

    +

    silly URL w/ angle brackets.

    diff --git a/test/php-markdown-extra-cases/Abbr.tags b/test/php-markdown-extra-cases/Abbr.tags new file mode 100644 index 00000000..0019958f --- /dev/null +++ b/test/php-markdown-extra-cases/Abbr.tags @@ -0,0 +1 @@ +knownfailure diff --git a/test/php-markdown-extra-cases/Definition Lists.tags b/test/php-markdown-extra-cases/Definition Lists.tags new file mode 100644 index 00000000..0019958f --- /dev/null +++ b/test/php-markdown-extra-cases/Definition Lists.tags @@ -0,0 +1 @@ +knownfailure diff --git a/test/php-markdown-extra-cases/Emphasis.tags b/test/php-markdown-extra-cases/Emphasis.tags new file mode 100644 index 00000000..0019958f --- /dev/null +++ b/test/php-markdown-extra-cases/Emphasis.tags @@ -0,0 +1 @@ +knownfailure diff --git a/test/php-markdown-extra-cases/Footnotes.tags b/test/php-markdown-extra-cases/Footnotes.tags new file mode 100644 index 00000000..0019958f --- /dev/null +++ b/test/php-markdown-extra-cases/Footnotes.tags @@ -0,0 +1 @@ +knownfailure diff --git a/test/php-markdown-extra-cases/Inline HTML with Markdown content.tags b/test/php-markdown-extra-cases/Inline HTML with Markdown content.tags new file mode 100644 index 00000000..0019958f --- /dev/null +++ b/test/php-markdown-extra-cases/Inline HTML with Markdown content.tags @@ -0,0 +1 @@ +knownfailure diff --git a/test/php-markdown-extra-cases/Tables.html b/test/php-markdown-extra-cases/Tables.html index e36286c8..92b6a5aa 100644 --- a/test/php-markdown-extra-cases/Tables.html +++ b/test/php-markdown-extra-cases/Tables.html @@ -133,56 +133,56 @@

    One-column one-row table


    -

    Table alignement:

    +

    Table alignment:

    - - - + + + - - - + + + - - - + + +
    DefaultRightCenterLeftLeftCenterRight
    Long CellLong CellLong CellLong CellLong CellLong CellLong Cell
    CellCellCellCellCellCellCell
    -

    Table alignement (alternate spacing):

    +

    Table alignment (alternate spacing):

    - - - + + + - - - + + + - - - + + +
    DefaultRightCenterLeftLeftCenterRight
    Long CellLong CellLong CellLong CellLong CellLong CellLong Cell
    CellCellCellCellCellCellCell
    @@ -307,4 +307,25 @@

    Missing tailing pipe

    Cell - \ No newline at end of file + + +

    With a space at the end of the underline row

    + + + + + + + + + + + + + + + + + + +
    Header 1Header 2
    Cell 1Cell 2
    Cell 3Cell 4
    diff --git a/test/php-markdown-extra-cases/Tables.opts b/test/php-markdown-extra-cases/Tables.opts new file mode 100644 index 00000000..23983798 --- /dev/null +++ b/test/php-markdown-extra-cases/Tables.opts @@ -0,0 +1 @@ +{"extras": ["tables"]} diff --git a/test/php-markdown-extra-cases/Tables.text b/test/php-markdown-extra-cases/Tables.text index 71b93ca6..1c1d31cb 100644 --- a/test/php-markdown-extra-cases/Tables.text +++ b/test/php-markdown-extra-cases/Tables.text @@ -50,19 +50,19 @@ With leading and tailing pipes: * * * -Table alignement: +Table alignment: -| Default | Right | Center | Left | +| Default | Left | Center | Right | | --------- |:--------- |:---------:| ---------:| | Long Cell | Long Cell | Long Cell | Long Cell | -| Cell | Cell | Cell | Cell | +| Cell | Cell | Cell | Cell | -Table alignement (alternate spacing): +Table alignment (alternate spacing): -| Default | Right | Center | Left | +| Default | Left | Center | Right | | --------- | :-------- | :-------: | --------: | | Long Cell | Long Cell | Long Cell | Long Cell | -| Cell | Cell | Cell | Cell | +| Cell | Cell | Cell | Cell | * * * @@ -73,10 +73,10 @@ Table alignement (alternate spacing): | A | B | | C | | -Header 1 | Header 2 ---------- | --------- -A | B - | D +| Header 1 | Header 2 +| --------- | --------- +| A | B +| | D * * * @@ -102,3 +102,9 @@ Header 1 | Header 2 | Cell | Cell | Cell | Cell +# With a space at the end of the underline row + +Header 1 | Header 2 | +--------- | --------- | +Cell 1 | Cell 2 | +Cell 3 | Cell 4 | diff --git a/test/test.py b/test/test.py index c69df78f..995db47a 100755 --- a/test/test.py +++ b/test/test.py @@ -4,11 +4,11 @@ """The markdown2 test suite entry point.""" +import importlib import os -from os.path import exists, join, abspath, dirname, normpath +from os.path import join, abspath, dirname import sys import logging - import testlib log = logging.getLogger("test") @@ -24,25 +24,37 @@ def setup(): # Attempt to get 'pygments' on the import path. try: # If already have it, use that one. - import pygments + import pygments # noqa except ImportError: pygments_dir = join(top_dir, "deps", "pygments") - if sys.version_info[0] <= 2: - sys.path.insert(0, pygments_dir) - else: - sys.path.insert(0, pygments_dir + "3") + sys.path.insert(0, pygments_dir + "3") if __name__ == "__main__": logging.basicConfig() setup() default_tags = [] - try: - import pygments - except ImportError: - log.warning("skipping pygments tests ('pygments' module not found)") - default_tags.append("-pygments") + warnings = [] + for extra_lib in ('pygments', 'wavedrom', 'latex2mathml'): + try: + mod = importlib.import_module(extra_lib) + except ImportError: + warnings.append("skipping {} tests ('{}' module not found)".format(extra_lib, extra_lib)) + default_tags.append("-%s" % extra_lib) + else: + if extra_lib == 'pygments': + version = tuple(int(i) for i in mod.__version__.split('.')[:3]) + if version >= (2, 14, 0): + tag = "pygments<2.14" + else: + tag = "pygments>=2.14" + warnings.append("skipping {} tests (pygments {} found)".format(tag, mod.__version__)) + default_tags.append("-%s" % tag) retval = testlib.harness(testdir_from_ns=testdir_from_ns, default_tags=default_tags) + + for warning in warnings: + log.warning(warning) + sys.exit(retval) diff --git a/test/test_markdown2.py b/test/test_markdown2.py old mode 100644 new mode 100755 index d0b3133f..06313af9 --- a/test/test_markdown2.py +++ b/test/test_markdown2.py @@ -9,14 +9,12 @@ from os.path import join, dirname, abspath, exists, splitext, basename import re from glob import glob -from pprint import pprint import unittest import codecs import difflib import doctest from json import loads as json_loads - -from testlib import TestError, TestSkipped, tag +import warnings sys.path.insert(0, join(dirname(dirname(abspath(__file__))))) try: @@ -24,26 +22,6 @@ finally: del sys.path[0] - - -#---- Python version compat - -# Use `bytes` for byte strings and `unicode` for unicode strings (str in Py3). -if sys.version_info[0] <= 2: - py3 = False - try: - bytes - except NameError: - bytes = str - base_string_type = basestring -elif sys.version_info[0] >= 3: - py3 = True - unicode = str - base_string_type = str - unichr = chr - - - #---- Test cases class _MarkdownTestCase(unittest.TestCase): @@ -126,12 +104,8 @@ def _assertMarkdown(self, text, html, text_path=None, html_path=None, def charreprreplace(exc): if not isinstance(exc, UnicodeEncodeError): raise TypeError("don't know how to handle %r" % exc) - if py3: - obj_repr = repr(exc.object[exc.start:exc.end])[1:-1] - else: - # repr -> remote "u'" and "'" - obj_repr = repr(exc.object[exc.start:exc.end])[2:-1] - return (unicode(obj_repr), exc.end) + obj_repr = repr(exc.object[exc.start:exc.end])[1:-1] + return (str(obj_repr), exc.end) codecs.register_error("charreprreplace", charreprreplace) self.assertEqual(python_norm_html, norm_html, errmsg) @@ -177,11 +151,14 @@ def generate_tests(cls): opts_path = splitext(text_path)[0] + ".opts" if exists(opts_path): try: - opts = eval(open(opts_path, 'r').read()) + with warnings.catch_warnings(record=True) as caught_warnings: + opts = eval(open(opts_path).read()) + for warning in caught_warnings: + print("WARNING: loading %s generated warning: %s - lineno %d" % (opts_path, warning.message, warning.lineno), file=sys.stderr) except Exception: _, ex, _ = sys.exc_info() print("WARNING: couldn't load `%s' opts file: %s" \ - % (opts_path, ex)) + % (opts_path, ex), file=sys.stderr) toc_html_path = splitext(text_path)[0] + ".toc_html" if not exists(toc_html_path): @@ -230,7 +207,6 @@ class PHPMarkdownExtraTestCase(_MarkdownTestCase): syntax no implemented in markdown2.py. See for details. """ - __tags__ = ["knownfailure"] cases_dir = "php-markdown-extra-cases" @@ -286,24 +262,63 @@ def test_pre(self): '

    some starter text

    \n\n
    #!/usr/bin/python\nprint "hi"\n
    \n') def test_russian(self): - ko = '\u043b\u0449' # 'ko' on russian keyboard + ko = '\\u043b\\u0449' # 'ko' on russian keyboard self._assertMarkdown("## %s" % ko, '

    %s

    \n' % ko) test_russian.tags = ["unicode", "issue3"] + def test_toc_with_persistent_object(self): + """ + Tests that the toc is the same every time it's run on HTML, even if the Markdown object isn't disposed of. + """ + md = markdown2.Markdown(extras=["toc"]) + html = """ +# Header 1 +## Header 1.1 +## Header 1.2 +### Header 1.3 +# Header 2 +## Header 2.1 + """ + expected_toc_html = """ +""" + self.assertEqual(expected_toc_html, md.convert(html).toc_html) + # Do it again, to check if the toc_html is just appended rather than replaced + self.assertEqual(expected_toc_html, md.convert(html).toc_html) + # Create different html, and confirm toc_html is replaced + html = """ +# I'm new html +## I don't have to be long, just different +""" + expected_toc_html = """ +""" + self.assertEqual(expected_toc_html, md.convert(html).toc_html) + test_toc_with_persistent_object.tags = ["toc", "issue208"] + class DocTestsTestCase(unittest.TestCase): def test_api(self): test = doctest.DocFileTest("api.doctests") test.runTest() - # Don't bother on Python 3 because (a) there aren't many inline doctests, - # and (b) they are more to be didactic than comprehensive test suites. - if not py3: - def test_internal(self): - doctest.testmod(markdown2) - - #---- internal support stuff @@ -311,16 +326,16 @@ def test_internal(self): def _xml_escape_sub(match): escape = match.group(1) if escape[0] == 'x': - return unichr(int('0'+escape, base=16)) + return chr(int('0'+escape, base=16)) else: - return unichr(int(escape)) + return chr(int(escape)) _markdown_email_link_re = re.compile(r'(.*?)', re.U) def _markdown_email_link_sub(match): href, text = match.groups() href = _xml_escape_re.sub(_xml_escape_sub, href) text = _xml_escape_re.sub(_xml_escape_sub, text) - return '%s' % (href, text) + return '{}'.format(href, text) def norm_html_from_html(html): """Normalize (somewhat) Markdown'd HTML. @@ -330,18 +345,17 @@ def norm_html_from_html(html): Also normalize EOLs. """ - if not isinstance(html, unicode): + if not isinstance(html, str): html = html.decode('utf-8') html = _markdown_email_link_re.sub( _markdown_email_link_sub, html) - if sys.platform == "win32": - html = html.replace('\r\n', '\n') + html = html.replace('\r\n', '\n') return html def _display(s): """Markup the given string for useful display.""" - if not isinstance(s, unicode): + if not isinstance(s, str): s = s.decode("utf-8") s = _indent(_escaped_text_from_text(s, "whitespace"), 4) if not s.endswith('\n'): @@ -488,7 +502,7 @@ def _escaped_text_from_text(text, escapes="eol"): # - Add _escaped_html_from_text() with a similar call sig. import re - if isinstance(escapes, base_string_type): + if isinstance(escapes, str): if escapes == "eol": escapes = {'\r\n': "\\r\\n\r\n", '\n': "\\n\n", '\r': "\\r\r"} elif escapes == "whitespace": diff --git a/test/test_redos.py b/test/test_redos.py new file mode 100644 index 00000000..180ce931 --- /dev/null +++ b/test/test_redos.py @@ -0,0 +1,90 @@ +import logging +import subprocess +import sys +import time +from pathlib import Path + +log = logging.getLogger("test") +LIB_DIR = Path(__file__).parent.parent / "lib" + + +def pull_387_example_1(): + # https://github.com/trentm/python-markdown2/pull/387 + return "[#a" + " " * 3456 + + +def pull_387_example_2(): + # https://github.com/trentm/python-markdown2/pull/387 + return "```" + "\n" * 3456 + + +def pull_387_example_3(): + # https://github.com/trentm/python-markdown2/pull/387 + return "-*-" + " " * 3456 + + +def pull_402(): + # https://github.com/trentm/python-markdown2/pull/402 + return " " * 100_000 + "$" + + +def issue493(): + # https://github.com/trentm/python-markdown2/issues/493 + return "**_" + "*_" * 38730 * 10 + "\x00" + + +def issue_633(): + # https://github.com/trentm/python-markdown2/issues/633 + return '

    max_time + tolerance: - raise DurationError(('Test was too long (%.2f s)' - % total_time)) + raise DurationError('Test was too long (%.2f s)' + % total_time) return wrapper return _timedtest @@ -144,7 +140,7 @@ def wrapper(*args, **kw): #---- module api -class Test(object): +class Test: def __init__(self, ns, testmod, testcase, testfn_name, testsuite_class=None): self.ns = ns @@ -238,13 +234,12 @@ def testmods_from_testdir(testdir): testmod_name = splitext(basename(testmod_path))[0] log.debug("import test module '%s'", testmod_path) try: - iinfo = imp.find_module(testmod_name, [dirname(testmod_path)]) testabsdir = abspath(testdir) sys.path.insert(0, testabsdir) old_dir = os.getcwd() os.chdir(testdir) try: - testmod = imp.load_module(testmod_name, *iinfo) + testmod = importlib.import_module(testmod_name) finally: os.chdir(old_dir) sys.path.remove(testabsdir) @@ -444,7 +439,7 @@ def list_tests(testdir_from_ns, tags): if testfile.endswith(".pyc"): testfile = testfile[:-1] print("%s:" % t.shortname()) - print(" from: %s#%s.%s" % (testfile, + print(" from: {}#{}.{}".format(testfile, t.testcase.__class__.__name__, t.testfn_name)) wrapped = textwrap.fill(' '.join(t.tags()), WIDTH-10) print(" tags: %s" % _indent(wrapped, 8, True)) @@ -475,7 +470,7 @@ def __init__(self, stream): def getDescription(self, test): if test._testlib_explicit_tags_: - return "%s [%s]" % (test._testlib_shortname_, + return "{} [{}]".format(test._testlib_shortname_, ', '.join(test._testlib_explicit_tags_)) else: return test._testlib_shortname_ @@ -519,7 +514,7 @@ def printErrorList(self, flavour, errors): self.stream.write("%s\n" % err) -class ConsoleTestRunner(object): +class ConsoleTestRunner: """A test runner class that displays results on the console. It prints out the names of tests as they are run, errors as they diff --git a/test/tm-cases/admonitions.html b/test/tm-cases/admonitions.html new file mode 100644 index 00000000..e8a7d05e --- /dev/null +++ b/test/tm-cases/admonitions.html @@ -0,0 +1,53 @@ +

    + + + +

    Otherwise the text is no longer part of the admonition.

    + + + +
    print('In case you wanted something like')
    +print('an indented code block right after')
    +
    + + diff --git a/test/tm-cases/admonitions.opts b/test/tm-cases/admonitions.opts new file mode 100644 index 00000000..44e237fc --- /dev/null +++ b/test/tm-cases/admonitions.opts @@ -0,0 +1 @@ +{"extras": ["admonitions"]} \ No newline at end of file diff --git a/test/tm-cases/admonitions.text b/test/tm-cases/admonitions.text new file mode 100644 index 00000000..b79ff8a1 --- /dev/null +++ b/test/tm-cases/admonitions.text @@ -0,0 +1,38 @@ +.. NOTE:: Admonitions + They contain 3 main parts, the admonition type, title and body. + + The admonition type is case insensitive, title is optional and the body + should be able to contain pretty much anything. For example: + + - Lists + - With multiple levels + - Of indentation + + And code blocks: + + print('indented code blocks') + +.. warning:: + The admonition's body must be indented by a tab or 3 or more spaces + from where the admonition was declared + Otherwise the text is no longer part of the admonition. + +.. IMPORTANT:: + You can also use 3 or more empty lines after an admonition + to end it + + + + print('In case you wanted something like') + print('an indented code block right after') + +.. admonition:: Generic admonitions + + These should be given a title but this is not enforced + + .. note:: Nested admonitions + Nested admonitions should also work + + - Even inside + .. tip:: + of a list \ No newline at end of file diff --git a/test/tm-cases/admonitions_with_fenced_code_blocks.html b/test/tm-cases/admonitions_with_fenced_code_blocks.html new file mode 100644 index 00000000..7428c571 --- /dev/null +++ b/test/tm-cases/admonitions_with_fenced_code_blocks.html @@ -0,0 +1,35 @@ + + + + +
    +
    # admonitions WITHIN fenced code blocks should NOT be rendered
    +.. attention:: title
    +   body
    +
    +
    diff --git a/test/tm-cases/admonitions_with_fenced_code_blocks.opts b/test/tm-cases/admonitions_with_fenced_code_blocks.opts new file mode 100644 index 00000000..145a5305 --- /dev/null +++ b/test/tm-cases/admonitions_with_fenced_code_blocks.opts @@ -0,0 +1 @@ +{"extras": ["admonitions", "fenced-code-blocks", "pygments"]} \ No newline at end of file diff --git a/test/tm-cases/admonitions_with_fenced_code_blocks.tags b/test/tm-cases/admonitions_with_fenced_code_blocks.tags new file mode 100644 index 00000000..f0d7f9c4 --- /dev/null +++ b/test/tm-cases/admonitions_with_fenced_code_blocks.tags @@ -0,0 +1 @@ +extra admonitions fenced-code-blocks pygments diff --git a/test/tm-cases/admonitions_with_fenced_code_blocks.text b/test/tm-cases/admonitions_with_fenced_code_blocks.text new file mode 100644 index 00000000..9a04bee2 --- /dev/null +++ b/test/tm-cases/admonitions_with_fenced_code_blocks.text @@ -0,0 +1,23 @@ +.. note:: + Admonitions are able to contain fenced code blocks + ```python + print('like so') + ``` + +.. warning:: + ```python + print('Consecutive blocks should also be fine') + ``` + ```python + print('Even though fenced code blocks wrap themselves in newlines') + ``` + .. hint:: It should also work nested + ```python + print('ok') + ``` + +```python +# admonitions WITHIN fenced code blocks should NOT be rendered +.. attention:: title + body +``` \ No newline at end of file diff --git a/test/tm-cases/alerts.html b/test/tm-cases/alerts.html new file mode 100644 index 00000000..c5d957b3 --- /dev/null +++ b/test/tm-cases/alerts.html @@ -0,0 +1,24 @@ +
    +Note +

    Useful information that users should know, even when skimming content.

    +
    + +
    +Tip +

    Helpful advice for doing things better or more easily.

    +
    + +
    +Important +

    Key information users need to know to achieve their goal.

    +
    + +
    +Warning +

    Urgent info that needs immediate user attention to avoid problems.

    +
    + +
    +Caution +

    Advises about risks or negative outcomes of certain actions.

    +
    diff --git a/test/tm-cases/alerts.opts b/test/tm-cases/alerts.opts new file mode 100644 index 00000000..2913a414 --- /dev/null +++ b/test/tm-cases/alerts.opts @@ -0,0 +1 @@ +{"extras": ["alerts"]} diff --git a/test/tm-cases/alerts.text b/test/tm-cases/alerts.text new file mode 100644 index 00000000..b00ffbdd --- /dev/null +++ b/test/tm-cases/alerts.text @@ -0,0 +1,15 @@ +> [!NOTE] +> Useful information that users should know, even when skimming content. + +> [!TIP] +> Helpful advice for doing things better or more easily. + +> [!IMPORTANT] +> Key information users need to know to achieve their goal. + +> [!WARNING] +> Urgent info that needs immediate user attention to avoid problems. + +> [!CAUTION] +> +> Advises about risks or negative outcomes of certain actions. diff --git a/test/tm-cases/backslash_escape_empty_links.html b/test/tm-cases/backslash_escape_empty_links.html new file mode 100644 index 00000000..bffeaa51 --- /dev/null +++ b/test/tm-cases/backslash_escape_empty_links.html @@ -0,0 +1,4 @@ +

    link

    + +

    one
    +two

    diff --git a/test/tm-cases/backslash_escape_empty_links.opts b/test/tm-cases/backslash_escape_empty_links.opts new file mode 100644 index 00000000..7228a640 --- /dev/null +++ b/test/tm-cases/backslash_escape_empty_links.opts @@ -0,0 +1 @@ +{"extras": {"breaks": {"on_backslash": True}}} \ No newline at end of file diff --git a/test/tm-cases/backslash_escape_empty_links.text b/test/tm-cases/backslash_escape_empty_links.text new file mode 100644 index 00000000..95b3f7a1 --- /dev/null +++ b/test/tm-cases/backslash_escape_empty_links.text @@ -0,0 +1,4 @@ +[link]() + +one\ +two \ No newline at end of file diff --git a/test/tm-cases/backslash_escape_html_tags.html b/test/tm-cases/backslash_escape_html_tags.html new file mode 100644 index 00000000..51b070f4 --- /dev/null +++ b/test/tm-cases/backslash_escape_html_tags.html @@ -0,0 +1,13 @@ +

    this is <strong>some strong</strong> text

    + +

    <strong>text</strong>

    + +

    text \with double\ escapes

    + +

    how about text \<strong>with triple\</strong> escapes

    + +

    escaped auto-link <https://www.example.com> +not quite escaped auto link \https://www.example.com +escaped auto-link \<https://www.example.com>

    + +

    <!-- and escaped HTML comment --> \ \<!--and another that is-->

    diff --git a/test/tm-cases/backslash_escape_html_tags.text b/test/tm-cases/backslash_escape_html_tags.text new file mode 100644 index 00000000..e26bf2b5 --- /dev/null +++ b/test/tm-cases/backslash_escape_html_tags.text @@ -0,0 +1,13 @@ +this is \some strong\ text + +[\](http://localhost/)text\ + +text \\with double\\ escapes + +how about text \\\with triple\\\ escapes + +escaped auto-link \ +not quite escaped auto link \\ +escaped auto-link \\\ + +\ \\ \\\ \ No newline at end of file diff --git a/test/tm-cases/backslash_removed_by_adjacent_backtick.html b/test/tm-cases/backslash_removed_by_adjacent_backtick.html new file mode 100644 index 00000000..1091b1a7 --- /dev/null +++ b/test/tm-cases/backslash_removed_by_adjacent_backtick.html @@ -0,0 +1,7 @@ +

    hello \world

    + +

    hello \world my favourite letter is w

    + +

    hello \world my favourite code is import pickle

    + +

    hello \world my favourite letter is x

    diff --git a/test/tm-cases/backslash_removed_by_adjacent_backtick.text b/test/tm-cases/backslash_removed_by_adjacent_backtick.text new file mode 100644 index 00000000..4136c904 --- /dev/null +++ b/test/tm-cases/backslash_removed_by_adjacent_backtick.text @@ -0,0 +1,7 @@ +hello \world + +hello \world my favourite letter is `w` + +hello \world my favourite code is `import pickle` + +hello \world my favourite letter is `x` \ No newline at end of file diff --git a/test/tm-cases/basic_safe_mode.html b/test/tm-cases/basic_safe_mode.html index 435a3329..60051078 100644 --- a/test/tm-cases/basic_safe_mode.html +++ b/test/tm-cases/basic_safe_mode.html @@ -6,13 +6,13 @@

    [HTML_REMOVED]alert(1)[HTML_REMOVED]

    -

    link1

    +

    link1

    link2

    -

    link3

    +

    link3

    -

    link4 >[HTML_REMOVED]alert(1)[HTML_REMOVED]

    +

    link4 >[HTML_REMOVED]alert(1)[HTML_REMOVED]

    link5

    @@ -30,6 +30,6 @@

    <img src="/service/javascript:alert(1)"

    -

    ok img

    +

    ok img

    link ok

    diff --git a/test/tm-cases/basic_safe_mode_escape.html b/test/tm-cases/basic_safe_mode_escape.html index af24510c..cd4f04cc 100644 --- a/test/tm-cases/basic_safe_mode_escape.html +++ b/test/tm-cases/basic_safe_mode_escape.html @@ -3,3 +3,5 @@

    <div>yowzer!</div>

    blah

    + +

    foo <!-- bar

    diff --git a/test/tm-cases/basic_safe_mode_escape.text b/test/tm-cases/basic_safe_mode_escape.text index ee042312..baf11d10 100644 --- a/test/tm-cases/basic_safe_mode_escape.text +++ b/test/tm-cases/basic_safe_mode_escape.text @@ -3,3 +3,6 @@ blah blah
    yowzer!
    blah + + +*foo* + + + + + +content here + + there is supposed to be an image here + +Now some bullets: + + * one + * two + + + + + diff --git a/test/tm-cases/block_tags.text b/test/tm-cases/block_tags.text new file mode 100644 index 00000000..12ced98a --- /dev/null +++ b/test/tm-cases/block_tags.text @@ -0,0 +1,23 @@ + + + + + + + + +content here + + there is supposed to be an image here + +Now some bullets: + + * one + * two + + + + + diff --git a/test/tm-cases/blockquote_containing_empty_lines.html b/test/tm-cases/blockquote_containing_empty_lines.html new file mode 100644 index 00000000..e572602c --- /dev/null +++ b/test/tm-cases/blockquote_containing_empty_lines.html @@ -0,0 +1,5 @@ +
    +

    no way

    + +

    way

    +
    diff --git a/test/tm-cases/blockquote_containing_empty_lines.text b/test/tm-cases/blockquote_containing_empty_lines.text new file mode 100644 index 00000000..ea9460eb --- /dev/null +++ b/test/tm-cases/blockquote_containing_empty_lines.text @@ -0,0 +1,4 @@ +> no way +> +> +> way diff --git a/test/tm-cases/blockquote_two_in_a_row.html b/test/tm-cases/blockquote_two_in_a_row.html new file mode 100644 index 00000000..5d3be31b --- /dev/null +++ b/test/tm-cases/blockquote_two_in_a_row.html @@ -0,0 +1,7 @@ +
    +

    no way

    +
    + +
    +

    way

    +
    diff --git a/test/tm-cases/blockquote_two_in_a_row.text b/test/tm-cases/blockquote_two_in_a_row.text new file mode 100644 index 00000000..4ecb87e5 --- /dev/null +++ b/test/tm-cases/blockquote_two_in_a_row.text @@ -0,0 +1,3 @@ +> no way + +> way diff --git a/test/tm-cases/break_on_backslash.html b/test/tm-cases/break_on_backslash.html new file mode 100644 index 00000000..71a26425 --- /dev/null +++ b/test/tm-cases/break_on_backslash.html @@ -0,0 +1,6 @@ +

    Github flavoured markdown allows
    +you to insert a backslash with or +without a space, which results in
    +a hard line break, unless it has \ +been escaped. It's still possible to
    +end the line with two spaces for a line break.

    diff --git a/test/tm-cases/break_on_backslash.opts b/test/tm-cases/break_on_backslash.opts new file mode 100644 index 00000000..52f81fdc --- /dev/null +++ b/test/tm-cases/break_on_backslash.opts @@ -0,0 +1 @@ +{'extras': {'breaks': {'on_backslash': True}}} diff --git a/test/tm-cases/break_on_backslash.text b/test/tm-cases/break_on_backslash.text new file mode 100644 index 00000000..8a94983d --- /dev/null +++ b/test/tm-cases/break_on_backslash.text @@ -0,0 +1,6 @@ +Github flavoured markdown allows \ +you to insert a backslash with or +without a space, which results in\ +a hard line break, unless it has \\ +been escaped. It's still possible to +end the line with two spaces for a line break. diff --git a/test/tm-cases/break_on_newline_and_backslash.html b/test/tm-cases/break_on_newline_and_backslash.html new file mode 100644 index 00000000..17706d82 --- /dev/null +++ b/test/tm-cases/break_on_newline_and_backslash.html @@ -0,0 +1,3 @@ +

    The breaks extra allows you to insert a hard break on newlines.
    +You can also insert hard breaks after backslashes
    +which will result in a single break when both are enabled.

    diff --git a/test/tm-cases/break_on_newline_and_backslash.opts b/test/tm-cases/break_on_newline_and_backslash.opts new file mode 100644 index 00000000..5ac49b03 --- /dev/null +++ b/test/tm-cases/break_on_newline_and_backslash.opts @@ -0,0 +1 @@ +{'extras': {'breaks': {'on_backslash': True, 'on_newline': True}}} diff --git a/test/tm-cases/break_on_newline_and_backslash.text b/test/tm-cases/break_on_newline_and_backslash.text new file mode 100644 index 00000000..84c2b826 --- /dev/null +++ b/test/tm-cases/break_on_newline_and_backslash.text @@ -0,0 +1,3 @@ +The breaks extra allows you to insert a hard break on newlines. +You can also insert hard breaks after backslashes \ +which will result in a single break when both are enabled. diff --git a/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.html b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.html new file mode 100644 index 00000000..19075c61 --- /dev/null +++ b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.html @@ -0,0 +1,58 @@ +

    Conteúdo

    + +
      +
    • O que é estrutura Co-locada (on premises), o que é estrutura híbrida e o que é estrutura em-nuvem? +
        +
      • Em Nuvem (cloud based) +
          +
        • Uma estrutura em-nuvem tem todos os seus principais recursos providos por um provedor de serviços em nuvem. +
            +
          • Uma definição formal de serviço em nuvem pode ser: +
              +
            • Entrega via internet de um serviço de Tecnologia da Informação, sob demanda, em um modelo de pague-pelo-que-consome. +
                +
              • Brown Field é quando você migra um serviço existente
              • +
              • Green field é quando você começa do zero na nuvem, alguns também chamam isto de Cloud
              • +
            • +
          • +
        • +
      • +
    • +
    + +

    Ordered List

    + +
      +
    1. A +
        +
      1. B +
          +
        1. C +
            +
          1. D
          2. +
          3. E
          4. +
        2. +
      2. +
    2. +
    + +

    Mixed List

    + +
      +
    1. A +
        +
      • B +
          +
        1. C +
            +
          • D
          • +
          • E
          • +
        2. +
        3. F +
            +
          1. G
          2. +
          3. H
          4. +
        4. +
      • +
    2. +
    diff --git a/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.opts b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.opts new file mode 100644 index 00000000..a3d91cea --- /dev/null +++ b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.opts @@ -0,0 +1 @@ +{"extras": ["break-on-newline"]} \ No newline at end of file diff --git a/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.text b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.text new file mode 100644 index 00000000..aacdd9be --- /dev/null +++ b/test/tm-cases/break_on_newline_excessive_br_tags_in_ul.text @@ -0,0 +1,25 @@ +## Conteúdo +- O que é estrutura Co-locada (on premises), o que é estrutura híbrida e o que é estrutura em-nuvem? + - Em Nuvem (cloud based) + - Uma estrutura em-nuvem tem todos os seus principais recursos providos por um provedor de serviços em nuvem. + - Uma definição formal de serviço em nuvem pode ser: + - Entrega via internet de um serviço de Tecnologia da Informação, sob demanda, em um modelo de pague-pelo-que-consome. + - Brown Field é quando você migra um serviço existente + - Green field é quando você começa do zero na nuvem, alguns também chamam isto de Cloud + +## Ordered List +1. A + 1. B + 1. C + 1. D + 2. E + +## Mixed List +1. A + - B + 1. C + - D + - E + 2. F + 1. G + 2. H \ No newline at end of file diff --git a/test/tm-cases/code_friendly_bold.html b/test/tm-cases/code_friendly_bold.html new file mode 100644 index 00000000..a0c9b16d --- /dev/null +++ b/test/tm-cases/code_friendly_bold.html @@ -0,0 +1 @@ +

    bold_but_not_emphasized

    diff --git a/test/tm-cases/code_friendly_bold.opts b/test/tm-cases/code_friendly_bold.opts new file mode 100644 index 00000000..cd0b9d61 --- /dev/null +++ b/test/tm-cases/code_friendly_bold.opts @@ -0,0 +1 @@ +{"extras": ["code-friendly"]} diff --git a/test/tm-cases/code_friendly_bold.text b/test/tm-cases/code_friendly_bold.text new file mode 100644 index 00000000..c50ffd25 --- /dev/null +++ b/test/tm-cases/code_friendly_bold.text @@ -0,0 +1 @@ +**bold_but_not_emphasized** diff --git a/test/tm-cases/code_friendly_issue638.html b/test/tm-cases/code_friendly_issue638.html new file mode 100644 index 00000000..c28476e3 --- /dev/null +++ b/test/tm-cases/code_friendly_issue638.html @@ -0,0 +1 @@ +

    a_b this should be bold c_d this is bold

    diff --git a/test/tm-cases/code_friendly_issue638.opts b/test/tm-cases/code_friendly_issue638.opts new file mode 100644 index 00000000..245e9828 --- /dev/null +++ b/test/tm-cases/code_friendly_issue638.opts @@ -0,0 +1 @@ +{"extras":["code-friendly"]} \ No newline at end of file diff --git a/test/tm-cases/code_friendly_issue638.text b/test/tm-cases/code_friendly_issue638.text new file mode 100644 index 00000000..a015bf5c --- /dev/null +++ b/test/tm-cases/code_friendly_issue638.text @@ -0,0 +1 @@ +a_b this should be **bold** c_d this is **bold** \ No newline at end of file diff --git a/test/tm-cases/code_friendly_issue646.html b/test/tm-cases/code_friendly_issue646.html new file mode 100644 index 00000000..5c8e0779 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.html @@ -0,0 +1 @@ +

    A_B

    diff --git a/test/tm-cases/code_friendly_issue646.opts b/test/tm-cases/code_friendly_issue646.opts new file mode 100644 index 00000000..245e9828 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.opts @@ -0,0 +1 @@ +{"extras":["code-friendly"]} \ No newline at end of file diff --git a/test/tm-cases/code_friendly_issue646.text b/test/tm-cases/code_friendly_issue646.text new file mode 100644 index 00000000..8f94c786 --- /dev/null +++ b/test/tm-cases/code_friendly_issue646.text @@ -0,0 +1 @@ +A_**B** \ No newline at end of file diff --git a/test/tm-cases/codespans_inside_link_text.html b/test/tm-cases/codespans_inside_link_text.html new file mode 100644 index 00000000..48027cfb --- /dev/null +++ b/test/tm-cases/codespans_inside_link_text.html @@ -0,0 +1,3 @@ +

    example

    + +

    more examples

    diff --git a/test/tm-cases/codespans_inside_link_text.text b/test/tm-cases/codespans_inside_link_text.text new file mode 100644 index 00000000..92bbab93 --- /dev/null +++ b/test/tm-cases/codespans_inside_link_text.text @@ -0,0 +1,3 @@ +[`example`](https://example.com) + +[more `examples`](https://example.com) \ No newline at end of file diff --git a/test/tm-cases/consecutive_image_links_issue498.html b/test/tm-cases/consecutive_image_links_issue498.html new file mode 100644 index 00000000..776f324a --- /dev/null +++ b/test/tm-cases/consecutive_image_links_issue498.html @@ -0,0 +1,4 @@ +

    A +A +A +A

    diff --git a/test/tm-cases/consecutive_image_links_issue498.text b/test/tm-cases/consecutive_image_links_issue498.text new file mode 100644 index 00000000..34a6a5cb --- /dev/null +++ b/test/tm-cases/consecutive_image_links_issue498.text @@ -0,0 +1,4 @@ +[![A](https://img.shields.io/badge/license-AGPL--3.0-orange?style=flat-square&color=0f6adb&logo=github)](https://github.com/aoaostar) +[![A](https://img.shields.io/badge/license-AGPL--3.0-orange?style=flat-square&color=0f6adb&logo=github)](https://github.com/aoaostar) +[![A](https://img.shields.io/badge/license-AGPL--3.0-orange?style=flat-square&color=0f6adb&logo=github)](https://github.com/aoaostar) +[![A](https://img.shields.io/badge/license-AGPL--3.0-orange?style=flat-square&color=0f6adb&logo=github)](https://github.com/aoaostar) \ No newline at end of file diff --git a/test/tm-cases/consecutive_strong_and_em.html b/test/tm-cases/consecutive_strong_and_em.html new file mode 100644 index 00000000..6478dd07 --- /dev/null +++ b/test/tm-cases/consecutive_strong_and_em.html @@ -0,0 +1 @@ +

    strongemstrong

    diff --git a/test/tm-cases/consecutive_strong_and_em.text b/test/tm-cases/consecutive_strong_and_em.text new file mode 100644 index 00000000..663723f9 --- /dev/null +++ b/test/tm-cases/consecutive_strong_and_em.text @@ -0,0 +1 @@ +**strong***em***strong** diff --git a/test/tm-cases/consecutive_strong_em.html b/test/tm-cases/consecutive_strong_em.html new file mode 100644 index 00000000..b2e92c7b --- /dev/null +++ b/test/tm-cases/consecutive_strong_em.html @@ -0,0 +1,7 @@ +

    a b c

    + +

    a b c

    + +

    a b c

    + +

    a b c

    diff --git a/test/tm-cases/consecutive_strong_em.text b/test/tm-cases/consecutive_strong_em.text new file mode 100644 index 00000000..1fde0000 --- /dev/null +++ b/test/tm-cases/consecutive_strong_em.text @@ -0,0 +1,7 @@ +**a** b **c** + +*a* b *c* + +__a__ b __c__ + +_a_ b _c_ diff --git a/test/tm-cases/data_urls_in_safe_mode.html b/test/tm-cases/data_urls_in_safe_mode.html new file mode 100644 index 00000000..587d980d --- /dev/null +++ b/test/tm-cases/data_urls_in_safe_mode.html @@ -0,0 +1,3 @@ +

    smiley

    + +

    smiley

    diff --git a/test/tm-cases/data_urls_in_safe_mode.opts b/test/tm-cases/data_urls_in_safe_mode.opts new file mode 100644 index 00000000..ccb6a09b --- /dev/null +++ b/test/tm-cases/data_urls_in_safe_mode.opts @@ -0,0 +1 @@ +{'safe_mode': True} diff --git a/test/tm-cases/data_urls_in_safe_mode.text b/test/tm-cases/data_urls_in_safe_mode.text new file mode 100644 index 00000000..512c6119 --- /dev/null +++ b/test/tm-cases/data_urls_in_safe_mode.text @@ -0,0 +1,3 @@ +![smiley](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=) + +[smiley](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+jQ12RyohqqoYoo8RDwJrU+qXkjWtfi8Xxt58BdQuwQs9qC/afLwCw8tnQbqYAPsgxE1S6F3EAIXux2oQFKm0ihMsOF71dHYx+f3NND68ghCu1YIoePPQN1pGRABkJ6Bus96CutRZMydTl+TvuiRW1m3n0eDl0vRPcEysqdXn+jsQPsrHMquGeXEaY4Yk4wxWcY5V/9scqOMOVUFthatyTy8QyqwZ+kDURKoMWxNKr2EeqVKcTNOajqKoBgOE28U4tdQl5p5bwCw7BWquaZSzAPlwjlithJtp3pTImSqQRrb2Z8PHGigD4RZuNX6JYj6wj7O4TFLbCO/Mn/m8R+h6rYSUb3ekokRY6f/YukArN979jcW+V/S8g0eT/N3VN3kTqWbQ428m9/8k0P/1aIhF36PccEl6EhOcAUCrXKZXXWS3XKd2vc/TRBG9O5ELC17MmWubD2nKhUKZa26Ba2+D3P+4/MNCFwg59oWVeYhkzgN/JDR8deKBoD7Y+ljEjGZ0sosXVTvbc6RHirr2reNy1OXd6pJsQ+gqjk8VWFYmHrwBzW/n+uMPFiRwHB2I7ih8ciHFxIkd/3Omk5tCDV1t+2nNu5sxxpDFNx+huNhVT3/zMDz8usXC3ddaHBj1GHj/As08fwTS7Kt1HBTmyN29vdwAw+/wbwLVOJ3uAD1wi/dUH7Qei66PfyuRj4Ik9is+hglfbkbfR3cnZm7chlUWLdwmprtCohX4HUtlOcQjLYCu+fzGJH2QRKvP3UNz8bWk1qMxjGTOMThZ3kvgLI5AzFfo379UAAAAASUVORK5CYII=) diff --git a/test/tm-cases/emacs_file_vars.html b/test/tm-cases/emacs_file_vars.html new file mode 100644 index 00000000..1ccd4c67 --- /dev/null +++ b/test/tm-cases/emacs_file_vars.html @@ -0,0 +1,6 @@ + + +

    This markdown text will be converted with the "footnotes" +extra enabled.

    + +

    This test should not raise any errors

    diff --git a/test/tm-cases/emacs_file_vars.opts b/test/tm-cases/emacs_file_vars.opts new file mode 100644 index 00000000..1db0c71f --- /dev/null +++ b/test/tm-cases/emacs_file_vars.opts @@ -0,0 +1 @@ +{"use_file_vars": True} \ No newline at end of file diff --git a/test/tm-cases/emacs_file_vars.text b/test/tm-cases/emacs_file_vars.text new file mode 100644 index 00000000..bc8bf213 --- /dev/null +++ b/test/tm-cases/emacs_file_vars.text @@ -0,0 +1,6 @@ +-*- markdown-extras: footnotes -*- + +This markdown text will be converted with the "footnotes" +extra enabled. + +This test should not raise any errors \ No newline at end of file diff --git a/test/tm-cases/emacs_file_vars_with_metadata.html b/test/tm-cases/emacs_file_vars_with_metadata.html new file mode 100644 index 00000000..bed68625 --- /dev/null +++ b/test/tm-cases/emacs_file_vars_with_metadata.html @@ -0,0 +1,2 @@ + + diff --git a/test/tm-cases/emacs_file_vars_with_metadata.metadata b/test/tm-cases/emacs_file_vars_with_metadata.metadata new file mode 100644 index 00000000..a977d991 --- /dev/null +++ b/test/tm-cases/emacs_file_vars_with_metadata.metadata @@ -0,0 +1,3 @@ +{ + "key": "value" +} \ No newline at end of file diff --git a/test/tm-cases/emacs_file_vars_with_metadata.opts b/test/tm-cases/emacs_file_vars_with_metadata.opts new file mode 100644 index 00000000..1db0c71f --- /dev/null +++ b/test/tm-cases/emacs_file_vars_with_metadata.opts @@ -0,0 +1 @@ +{"use_file_vars": True} \ No newline at end of file diff --git a/test/tm-cases/emacs_file_vars_with_metadata.text b/test/tm-cases/emacs_file_vars_with_metadata.text new file mode 100644 index 00000000..83db1488 --- /dev/null +++ b/test/tm-cases/emacs_file_vars_with_metadata.text @@ -0,0 +1,5 @@ +--- +key: value +--- + +-*- markdown-extras: metadata -*- \ No newline at end of file diff --git a/test/tm-cases/empty_fenced_code_blocks.html b/test/tm-cases/empty_fenced_code_blocks.html new file mode 100644 index 00000000..70cbf9ca --- /dev/null +++ b/test/tm-cases/empty_fenced_code_blocks.html @@ -0,0 +1,20 @@ +
    +
    
    +
    +
    + +
    
    +
    + +

    Pygments removes the empty line whitespace from the next code block

    + +
    +
    
    +
    +
    + +
    
    +
    +
    +
    +
    diff --git a/test/tm-cases/empty_fenced_code_blocks.opts b/test/tm-cases/empty_fenced_code_blocks.opts new file mode 100644 index 00000000..ba411ac7 --- /dev/null +++ b/test/tm-cases/empty_fenced_code_blocks.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} diff --git a/test/tm-cases/empty_fenced_code_blocks.tags b/test/tm-cases/empty_fenced_code_blocks.tags new file mode 100644 index 00000000..2c03fb5d --- /dev/null +++ b/test/tm-cases/empty_fenced_code_blocks.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments diff --git a/test/tm-cases/empty_fenced_code_blocks.text b/test/tm-cases/empty_fenced_code_blocks.text new file mode 100644 index 00000000..edce91ae --- /dev/null +++ b/test/tm-cases/empty_fenced_code_blocks.text @@ -0,0 +1,20 @@ +```shell +``` + +``` +``` + +Pygments removes the empty line whitespace from the next code block +```shell + + + + +``` + +``` + + + + +``` diff --git a/test/tm-cases/ems_across_spans.html b/test/tm-cases/ems_across_spans.html new file mode 100644 index 00000000..daef521f --- /dev/null +++ b/test/tm-cases/ems_across_spans.html @@ -0,0 +1 @@ +

    _confusing ident is _confusing

    diff --git a/test/tm-cases/ems_across_spans.text b/test/tm-cases/ems_across_spans.text new file mode 100644 index 00000000..40cd465c --- /dev/null +++ b/test/tm-cases/ems_across_spans.text @@ -0,0 +1 @@ +**_confusing** ident is **_confusing** \ No newline at end of file diff --git a/test/tm-cases/encode_incomplete_tags_xss_issue625.html b/test/tm-cases/encode_incomplete_tags_xss_issue625.html new file mode 100644 index 00000000..c153cc1b --- /dev/null +++ b/test/tm-cases/encode_incomplete_tags_xss_issue625.html @@ -0,0 +1 @@ +

    <x><img src=x onerror=alert("xss")//><x>

    diff --git a/test/tm-cases/encode_incomplete_tags_xss_issue625.opts b/test/tm-cases/encode_incomplete_tags_xss_issue625.opts new file mode 100644 index 00000000..de64198e --- /dev/null +++ b/test/tm-cases/encode_incomplete_tags_xss_issue625.opts @@ -0,0 +1 @@ +{'safe_mode': 'escape'} \ No newline at end of file diff --git a/test/tm-cases/encode_incomplete_tags_xss_issue625.text b/test/tm-cases/encode_incomplete_tags_xss_issue625.text new file mode 100644 index 00000000..551c08a5 --- /dev/null +++ b/test/tm-cases/encode_incomplete_tags_xss_issue625.text @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/tm-cases/escape_html_comments_safe_mode.html b/test/tm-cases/escape_html_comments_safe_mode.html new file mode 100644 index 00000000..9b2b2bc9 --- /dev/null +++ b/test/tm-cases/escape_html_comments_safe_mode.html @@ -0,0 +1,3 @@ +

    foo <!-- bar

    + +

    foo <!-- bar -->

    diff --git a/test/tm-cases/escape_html_comments_safe_mode.opts b/test/tm-cases/escape_html_comments_safe_mode.opts new file mode 100644 index 00000000..f15d59b8 --- /dev/null +++ b/test/tm-cases/escape_html_comments_safe_mode.opts @@ -0,0 +1 @@ +{'safe_mode': 'escape'} diff --git a/test/tm-cases/escape_html_comments_safe_mode.text b/test/tm-cases/escape_html_comments_safe_mode.text new file mode 100644 index 00000000..c5f3eef2 --- /dev/null +++ b/test/tm-cases/escape_html_comments_safe_mode.text @@ -0,0 +1,3 @@ +*foo* diff --git a/test/tm-cases/fenced_code_blocks_issue327.html b/test/tm-cases/fenced_code_blocks_issue327.html new file mode 100644 index 00000000..16cfc633 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue327.html @@ -0,0 +1,22 @@ +

    Inner code blocks should not render as code blocks

    + +
    ```cpp
    +int x = 10;
    +```
    +
    + +

    Without language specifier

    + +
    ```
    +int x = 10;
    +```
    +
    + +

    Double nesting

    + +
    ````
    +```cpp
    +int x = 10;
    +```
    +````
    +
    diff --git a/test/tm-cases/fenced_code_blocks_issue327.opts b/test/tm-cases/fenced_code_blocks_issue327.opts new file mode 100644 index 00000000..91560387 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue327.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue327.tags b/test/tm-cases/fenced_code_blocks_issue327.tags new file mode 100644 index 00000000..2d244483 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue327.tags @@ -0,0 +1 @@ +extra fenced-code-blocks \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue327.text b/test/tm-cases/fenced_code_blocks_issue327.text new file mode 100644 index 00000000..88ad0c68 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue327.text @@ -0,0 +1,23 @@ +Inner code blocks should not render as code blocks + +```` +```cpp +int x = 10; +``` +```` + +Without language specifier +```` +``` +int x = 10; +``` +```` + +Double nesting +````` +```` +```cpp +int x = 10; +``` +```` +````` \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue355.html b/test/tm-cases/fenced_code_blocks_issue355.html new file mode 100644 index 00000000..6696ede4 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue355.html @@ -0,0 +1,12 @@ +
    +
    some code block
    +
    +
    + +
    yet another code block
    +
    + +

    new line:

    + +
    code everywhere
    +
    diff --git a/test/tm-cases/fenced_code_blocks_issue355.opts b/test/tm-cases/fenced_code_blocks_issue355.opts new file mode 100644 index 00000000..91560387 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue355.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue355.tags b/test/tm-cases/fenced_code_blocks_issue355.tags new file mode 100644 index 00000000..12bca88c --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue355.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue355.text b/test/tm-cases/fenced_code_blocks_issue355.text new file mode 100644 index 00000000..c7e33b1c --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue355.text @@ -0,0 +1,10 @@ +```python +some code block +``` +``` +yet another code block +``` +new line: +``` +code everywhere +``` \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue396.html b/test/tm-cases/fenced_code_blocks_issue396.html new file mode 100644 index 00000000..8a277829 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue396.html @@ -0,0 +1,4 @@ +
    a
    +b
    +c
    +
    diff --git a/test/tm-cases/fenced_code_blocks_issue396.opts b/test/tm-cases/fenced_code_blocks_issue396.opts new file mode 100644 index 00000000..91560387 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue396.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue396.text b/test/tm-cases/fenced_code_blocks_issue396.text new file mode 100644 index 00000000..041d79eb --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue396.text @@ -0,0 +1,5 @@ +``` +a +b +c +``` \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue426.html b/test/tm-cases/fenced_code_blocks_issue426.html new file mode 100644 index 00000000..ee3e8ae7 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue426.html @@ -0,0 +1,35 @@ +

    Django Templates

    + +

    NOTES

    + +
      +
    • The name should map to the URL.
    • +
    • No distro or app name prefix, they are namespaced by their dirs already
    • +
    • Since templates are made in python, the are named_with_underscores.html (not web style dashes).
    • +
    + +

    URL PARAMETERS IN THE TEMPLATE

    + +
      +
    • All views (except generic.View) from django.forms.generic inherit from ContextMixin
    • +
    • ContextMixin defines the method get_context_data:

      + +
      +
      def get_context_data(self, **kwargs):
      +    kwargs.setdefault('view', self)
      +    if self.extra_context is not None:
      +        kwargs.update(self.extra_context)
      +    return kwargs
      +
      +
      + +

      So when overriding one must be careful to extends super's kwargs:

      + +
      +
      def get_context_data(self, **kwargs):
      +    kwargs = super().get_context_data(**kwargs)
      +    kwargs['page_title'] = "Documentation"
      +    return kwargs
      +
      +
    • +
    diff --git a/test/tm-cases/fenced_code_blocks_issue426.opts b/test/tm-cases/fenced_code_blocks_issue426.opts new file mode 100644 index 00000000..20052b21 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue426.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks", "pygments"]} diff --git a/test/tm-cases/fenced_code_blocks_issue426.tags b/test/tm-cases/fenced_code_blocks_issue426.tags new file mode 100644 index 00000000..2c03fb5d --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue426.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments diff --git a/test/tm-cases/fenced_code_blocks_issue426.text b/test/tm-cases/fenced_code_blocks_issue426.text new file mode 100644 index 00000000..b272c762 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue426.text @@ -0,0 +1,26 @@ +# Django Templates + +## NOTES + +- The name should map to the URL. +- No distro or app name prefix, they are namespaced by their dirs already +- Since templates are made in python, the are `named_with_underscores.html` (not web style dashes). + +## URL PARAMETERS IN THE TEMPLATE + +- All views (except `generic.View`) from `django.forms.generic` inherit from `ContextMixin` +- `ContextMixin` defines the method `get_context_data`: + ```python + def get_context_data(self, **kwargs): + kwargs.setdefault('view', self) + if self.extra_context is not None: + kwargs.update(self.extra_context) + return kwargs + ``` + So when overriding one must be careful to extends `super`'s `kwargs`: + ```py + def get_context_data(self, **kwargs): + kwargs = super().get_context_data(**kwargs) + kwargs['page_title'] = "Documentation" + return kwargs + ``` \ No newline at end of file diff --git a/test/tm-cases/fenced_code_blocks_issue462.html b/test/tm-cases/fenced_code_blocks_issue462.html new file mode 100644 index 00000000..6049aa67 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue462.html @@ -0,0 +1,12 @@ +

    Section 1

    + +
    +
    x = 1
    +
    +
    + +

    Section 2

    + +
    +test +
    diff --git a/test/tm-cases/fenced_code_blocks_issue462.opts b/test/tm-cases/fenced_code_blocks_issue462.opts new file mode 100644 index 00000000..20052b21 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue462.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks", "pygments"]} diff --git a/test/tm-cases/fenced_code_blocks_issue462.tags b/test/tm-cases/fenced_code_blocks_issue462.tags new file mode 100644 index 00000000..2c03fb5d --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue462.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments diff --git a/test/tm-cases/fenced_code_blocks_issue462.text b/test/tm-cases/fenced_code_blocks_issue462.text new file mode 100644 index 00000000..1a01c576 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_issue462.text @@ -0,0 +1,11 @@ +# Section 1 + +```python +x = 1 +``` + +# Section 2 + +
    +test +
    diff --git a/test/tm-cases/fenced_code_blocks_leading_lang_space.html b/test/tm-cases/fenced_code_blocks_leading_lang_space.html index 8f7a090a..f5815e5e 100644 --- a/test/tm-cases/fenced_code_blocks_leading_lang_space.html +++ b/test/tm-cases/fenced_code_blocks_leading_lang_space.html @@ -1,3 +1,5 @@ -
    if True:
    -    print "hi"
    -
    +
    +
    if True:
    +    print "hi"
    +
    +
    diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight.html b/test/tm-cases/fenced_code_blocks_safe_highlight.html index df5bbec5..b77f50b1 100644 --- a/test/tm-cases/fenced_code_blocks_safe_highlight.html +++ b/test/tm-cases/fenced_code_blocks_safe_highlight.html @@ -1,12 +1,16 @@ -
    if True:
    -    print "hi"
    -
    +
    +
    if True:
    +    print "hi"
    +
    +

    That's using the fenced-code-blocks extra with Python syntax coloring, if pygments is installed. See http://github.github.com/github-flavored-markdown/.

    -
    def foo
    -    puts "hi"
    +
    +
    def foo
    +    puts "hi"
     end
    -
    +
    +
    diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight.tags b/test/tm-cases/fenced_code_blocks_safe_highlight.tags index 2c03fb5d..b5480365 100644 --- a/test/tm-cases/fenced_code_blocks_safe_highlight.tags +++ b/test/tm-cases/fenced_code_blocks_safe_highlight.tags @@ -1 +1 @@ -extra fenced-code-blocks pygments +extra fenced-code-blocks pygments pygments>=2.14 diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight_old.html b/test/tm-cases/fenced_code_blocks_safe_highlight_old.html new file mode 100644 index 00000000..105bd8c9 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_safe_highlight_old.html @@ -0,0 +1,16 @@ +
    +
    if True:
    +    print "hi"
    +
    +
    + +

    That's using the fenced-code-blocks extra with Python +syntax coloring, if pygments is installed. See +http://github.github.com/github-flavored-markdown/.

    + +
    +
    def foo
    +    puts "hi"
    +end
    +
    +
    diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight_old.opts b/test/tm-cases/fenced_code_blocks_safe_highlight_old.opts new file mode 100644 index 00000000..ca41f659 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_safe_highlight_old.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"], "safe_mode": "escape"} diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight_old.tags b/test/tm-cases/fenced_code_blocks_safe_highlight_old.tags new file mode 100644 index 00000000..46b22d25 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_safe_highlight_old.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments pygments<2.14 diff --git a/test/tm-cases/fenced_code_blocks_safe_highlight_old.text b/test/tm-cases/fenced_code_blocks_safe_highlight_old.text new file mode 100644 index 00000000..5c6181cf --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_safe_highlight_old.text @@ -0,0 +1,14 @@ +```python +if True: + print "hi" +``` + +That's using the *fenced-code-blocks* extra with Python +syntax coloring, if `pygments` is installed. See +. + +```ruby +def foo + puts "hi" +end +``` diff --git a/test/tm-cases/fenced_code_blocks_simple.html b/test/tm-cases/fenced_code_blocks_simple.html index 7d05a72f..e1889052 100644 --- a/test/tm-cases/fenced_code_blocks_simple.html +++ b/test/tm-cases/fenced_code_blocks_simple.html @@ -12,3 +12,16 @@
        is indentation maintained?
     
    + +

    Here's one in a list, with another one following (see #580):

    + +
      +
    • List 1 +
      code 1
      +
      +code 2
      +
    • +
    + +
    code 3
    +
    diff --git a/test/tm-cases/fenced_code_blocks_simple.text b/test/tm-cases/fenced_code_blocks_simple.text index 9f2aabad..76efcdd1 100644 --- a/test/tm-cases/fenced_code_blocks_simple.text +++ b/test/tm-cases/fenced_code_blocks_simple.text @@ -14,3 +14,16 @@ Here is one at the end of the file: ``` is indentation maintained? ``` + +Here's one in a list, with another one following (see #580): + +* List 1 + ``` + code 1 + + code 2 + ``` + +``` +code 3 +``` diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting.html b/test/tm-cases/fenced_code_blocks_syntax_highlighting.html index df5bbec5..b77f50b1 100644 --- a/test/tm-cases/fenced_code_blocks_syntax_highlighting.html +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting.html @@ -1,12 +1,16 @@ -
    if True:
    -    print "hi"
    -
    +
    +
    if True:
    +    print "hi"
    +
    +

    That's using the fenced-code-blocks extra with Python syntax coloring, if pygments is installed. See http://github.github.com/github-flavored-markdown/.

    -
    def foo
    -    puts "hi"
    +
    +
    def foo
    +    puts "hi"
     end
    -
    +
    +
    diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting.tags b/test/tm-cases/fenced_code_blocks_syntax_highlighting.tags index 2c03fb5d..b5480365 100644 --- a/test/tm-cases/fenced_code_blocks_syntax_highlighting.tags +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting.tags @@ -1 +1 @@ -extra fenced-code-blocks pygments +extra fenced-code-blocks pygments pygments>=2.14 diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.html b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.html new file mode 100644 index 00000000..105bd8c9 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.html @@ -0,0 +1,16 @@ +
    +
    if True:
    +    print "hi"
    +
    +
    + +

    That's using the fenced-code-blocks extra with Python +syntax coloring, if pygments is installed. See +http://github.github.com/github-flavored-markdown/.

    + +
    +
    def foo
    +    puts "hi"
    +end
    +
    +
    diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.opts b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.opts new file mode 100644 index 00000000..ba411ac7 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.tags b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.tags new file mode 100644 index 00000000..46b22d25 --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments pygments<2.14 diff --git a/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.text b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.text new file mode 100644 index 00000000..5c6181cf --- /dev/null +++ b/test/tm-cases/fenced_code_blocks_syntax_highlighting_old.text @@ -0,0 +1,14 @@ +```python +if True: + print "hi" +``` + +That's using the *fenced-code-blocks* extra with Python +syntax coloring, if `pygments` is installed. See +. + +```ruby +def foo + puts "hi" +end +``` diff --git a/test/tm-cases/fenced_code_blocks_syntax_indentation.html b/test/tm-cases/fenced_code_blocks_syntax_indentation.html index 11a7c241..eedd7c65 100644 --- a/test/tm-cases/fenced_code_blocks_syntax_indentation.html +++ b/test/tm-cases/fenced_code_blocks_syntax_indentation.html @@ -1,5 +1,7 @@ -
    def foo():
    -    print "foo"
    +
    +
    def foo():
    +    print "foo"
     
    -    print "bar"
    -
    + print "bar" +
    +
    diff --git a/test/tm-cases/footnotes_order_of_appearance.html b/test/tm-cases/footnotes_order_of_appearance.html new file mode 100644 index 00000000..803a5821 --- /dev/null +++ b/test/tm-cases/footnotes_order_of_appearance.html @@ -0,0 +1,34 @@ +
    + +

    title: testing the footnotes bug

    + +

    Lorem ipsum dolor sit amet. Aliqua cillum, eu velit.1 Velit deserunt adipiscing adipiscing ullamco exercitation.

    + +
      +
    • this is a list item
    • +
    • this is a list item2
    • +
    • this is a list item3
    • +
    + +

    Lorem ipsum dolor sit amet. Adipiscing4 adipiscing ullamco, exercitation sint. Exercitation sint, fugiat exercitation voluptate amet.

    + +
    +
    +
      +
    1. +

      this should be the first note 

      +
    2. + +
    3. +

      this should be the second note 

      +
    4. + +
    5. +

      this should be the third note 

      +
    6. + +
    7. +

      this should be the fourth note 

      +
    8. +
    +
    diff --git a/test/tm-cases/footnotes_order_of_appearance.opts b/test/tm-cases/footnotes_order_of_appearance.opts new file mode 100644 index 00000000..9dfee9e2 --- /dev/null +++ b/test/tm-cases/footnotes_order_of_appearance.opts @@ -0,0 +1 @@ +{"extras": ["footnotes"]} diff --git a/test/tm-cases/footnotes_order_of_appearance.text b/test/tm-cases/footnotes_order_of_appearance.text new file mode 100644 index 00000000..87df462e --- /dev/null +++ b/test/tm-cases/footnotes_order_of_appearance.text @@ -0,0 +1,15 @@ +--- +title: testing the footnotes bug +--- +Lorem ipsum dolor sit amet. Aliqua cillum, eu velit.[^note1] Velit deserunt adipiscing adipiscing ullamco exercitation. + +- this is a list item +- this is a list item[^note2] +- this is a list item[^note3] + +Lorem ipsum dolor sit amet. Adipiscing[^note4] adipiscing ullamco, exercitation sint. Exercitation sint, fugiat exercitation voluptate amet. + +[^note1]: this should be the first note +[^note2]: this should be the second note +[^note3]: this should be the third note +[^note4]: this should be the fourth note diff --git a/test/tm-cases/hash_html_blocks.html b/test/tm-cases/hash_html_blocks.html new file mode 100644 index 00000000..310fe3da --- /dev/null +++ b/test/tm-cases/hash_html_blocks.html @@ -0,0 +1,9 @@ +
    +

    Archons of the Colophon

    + + +

    by Paco Xander Nathan +

    + +
    diff --git a/test/tm-cases/hash_html_blocks.text b/test/tm-cases/hash_html_blocks.text new file mode 100644 index 00000000..f4a20b0f --- /dev/null +++ b/test/tm-cases/hash_html_blocks.text @@ -0,0 +1,6 @@ +
    +

    Archons of the Colophon

    +

    by Paco Xander Nathan +

    +
    diff --git a/test/tm-cases/hash_html_blocks_issue_508.html b/test/tm-cases/hash_html_blocks_issue_508.html new file mode 100644 index 00000000..2c176c15 --- /dev/null +++ b/test/tm-cases/hash_html_blocks_issue_508.html @@ -0,0 +1,12 @@ +
    +
    + +
    + +
    + +
    + +
      +
    • A
    • +
    diff --git a/test/tm-cases/hash_html_blocks_issue_508.text b/test/tm-cases/hash_html_blocks_issue_508.text new file mode 100644 index 00000000..dbe7342d --- /dev/null +++ b/test/tm-cases/hash_html_blocks_issue_508.text @@ -0,0 +1,7 @@ +
    +
    +
    +
    +
    + +- A diff --git a/test/tm-cases/hash_nested_html_blocks.html b/test/tm-cases/hash_nested_html_blocks.html new file mode 100644 index 00000000..1e7bc4cb --- /dev/null +++ b/test/tm-cases/hash_nested_html_blocks.html @@ -0,0 +1,7 @@ +
    +
    +
    x = 1
    +
    +
    + +
    diff --git a/test/tm-cases/hash_nested_html_blocks.opts b/test/tm-cases/hash_nested_html_blocks.opts new file mode 100644 index 00000000..9e6bd79a --- /dev/null +++ b/test/tm-cases/hash_nested_html_blocks.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks", "pygments"]} \ No newline at end of file diff --git a/test/tm-cases/hash_nested_html_blocks.tags b/test/tm-cases/hash_nested_html_blocks.tags new file mode 100644 index 00000000..2c03fb5d --- /dev/null +++ b/test/tm-cases/hash_nested_html_blocks.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments diff --git a/test/tm-cases/hash_nested_html_blocks.text b/test/tm-cases/hash_nested_html_blocks.text new file mode 100644 index 00000000..f5ad8bd1 --- /dev/null +++ b/test/tm-cases/hash_nested_html_blocks.text @@ -0,0 +1,5 @@ +
    +```python +x = 1 +``` +
    \ No newline at end of file diff --git a/test/tm-cases/header_ids_4.html b/test/tm-cases/header_ids_4.html index 0d6384ff..f2c32aa5 100644 --- a/test/tm-cases/header_ids_4.html +++ b/test/tm-cases/header_ids_4.html @@ -1,6 +1,6 @@ -

    Fruit заголовок really likes

    +

    Fruit заголовок really likes

    • apples
    • diff --git a/test/tm-cases/highlightjs_lang.html b/test/tm-cases/highlightjs_lang.html index 2ca1490a..6a691b45 100644 --- a/test/tm-cases/highlightjs_lang.html +++ b/test/tm-cases/highlightjs_lang.html @@ -1,23 +1,17 @@ -
      here is some cpp code
      +
      here is some cpp code
       
      -
      some lang-cpp code
      -
      - -
      and some language-cpp code
      -
      - -
      some code without highlighting
      +
      some code without highlighting
       

      That's using the fenced-code-blocks and highlightjs-lang extra.

      Here is an empty one (just to check):

      -
      
      +
      
       

      Here is one at the end of the file:

      -
          is indentation maintained?
      +
          is indentation maintained?
       
      diff --git a/test/tm-cases/highlightjs_lang.text b/test/tm-cases/highlightjs_lang.text index 9073ed34..b1c5882c 100644 --- a/test/tm-cases/highlightjs_lang.text +++ b/test/tm-cases/highlightjs_lang.text @@ -2,14 +2,6 @@ here is some cpp code ``` -```lang-cpp -some lang-cpp code -``` - -```language-cpp -and some language-cpp code -``` - ```nohighlight some code without highlighting ``` diff --git a/test/tm-cases/hr_uniform_characters.html b/test/tm-cases/hr_uniform_characters.html new file mode 100644 index 00000000..2e5a7b95 --- /dev/null +++ b/test/tm-cases/hr_uniform_characters.html @@ -0,0 +1,48 @@ +

      Horizontal rules should probably consist of all of the same characters +EG:

      + +
      + +

      Or

      + +
      + +

      Or

      + +
      + +

      But not any of:

      + +

      --*

      + +

      -*-

      + +

      -**

      + +

      *--

      + +

      -

      + +

      **-

      + +

      **_

      + +

      _

      + +

      *__

      + +

      _**

      + +

      *

      + +

      __-

      + +

      -

      + +

      _--

      + +

      -__

      + +

      -_-

      + +

      --_

      diff --git a/test/tm-cases/hr_uniform_characters.text b/test/tm-cases/hr_uniform_characters.text new file mode 100644 index 00000000..8d5b69d8 --- /dev/null +++ b/test/tm-cases/hr_uniform_characters.text @@ -0,0 +1,49 @@ +Horizontal rules should probably consist of all of the same characters +EG: + +*** + +Or + +--- + +Or + +___ + + +But not any of: + +--* + +-*- + +-** + +*-- + +*-* + +**- + +**_ + +*_* + +*__ + +_** + +_*_ + +__- + +_-_ + +_-- + +-__ + +-_- + +--_ \ No newline at end of file diff --git a/test/tm-cases/html_classes.html b/test/tm-cases/html_classes.html index e5d4bc00..4caa7921 100644 --- a/test/tm-cases/html_classes.html +++ b/test/tm-cases/html_classes.html @@ -1,5 +1,5 @@ - + @@ -7,7 +7,7 @@ - + @@ -18,12 +18,30 @@
      Header 1 Header 2
      Cell 1Cell 1 Cell 2 link
      - - - - - - + + + + + + + + + + + + + + + + + + + + + + + +
      YearTemperature (low)Temperature (high)
      1900-1025
      1910-1530
      1920-1032
      YearTemperature (low)Temperature (high)
      1900-1025
      1910-1530
      1920-1032

      For example:

      @@ -32,4 +50,19 @@ print doit()
      -

      the google logo

      +

      the google logo +Unordered list:

      + +
        +
      • Item 1
      • +
      • Item 2
      • +
      • Item 3
      • +
      + +

      Ordered list:

      + +
        +
      1. Item 1
      2. +
      3. Item 2
      4. +
      5. Item 3
      6. +
      diff --git a/test/tm-cases/html_classes.opts b/test/tm-cases/html_classes.opts index 828be323..2a11cef3 100644 --- a/test/tm-cases/html_classes.opts +++ b/test/tm-cases/html_classes.opts @@ -7,7 +7,10 @@ "code": "codesyntaxcolor", "img": "custom-image-class", "table": "table table-striped", + "thead": "table-light", "p": "col-xs-3 custom-paragraph-class", + "ul": "custom-unordered-list-class", + "ol": "custom-ordered-list-class" } } } diff --git a/test/tm-cases/html_classes.text b/test/tm-cases/html_classes.text index 61972c80..4cacc579 100644 --- a/test/tm-cases/html_classes.text +++ b/test/tm-cases/html_classes.text @@ -3,7 +3,7 @@ | `Cell 1` | [Cell 2](http://example.com) link | | Cell 3 | **Cell 4** | -|| *Year* || *Temperature (low)* || *Temperature (high)* || +||~ Year ||~ Temperature (low) ||~ Temperature (high) || || 1900 || -10 || 25 || || 1910 || -15 || 30 || || 1920 || -10 || 32 || @@ -16,3 +16,15 @@ For example: ![the google logo][logo] [logo]: http://www.google.com/images/logo.gif + +Unordered list: + +* Item 1 +* Item 2 +* Item 3 + +Ordered list: + +1. Item 1 +2. Item 2 +3. Item 3 \ No newline at end of file diff --git a/test/tm-cases/html_classes_is_none.html b/test/tm-cases/html_classes_is_none.html new file mode 100644 index 00000000..aaecf804 --- /dev/null +++ b/test/tm-cases/html_classes_is_none.html @@ -0,0 +1,2 @@ +
      print("hello world")
      +
      diff --git a/test/tm-cases/html_classes_is_none.opts b/test/tm-cases/html_classes_is_none.opts new file mode 100644 index 00000000..f1411169 --- /dev/null +++ b/test/tm-cases/html_classes_is_none.opts @@ -0,0 +1 @@ +{"extras": ["html-classes", "fenced-code-blocks"]} \ No newline at end of file diff --git a/test/tm-cases/html_classes_is_none.tags b/test/tm-cases/html_classes_is_none.tags new file mode 100644 index 00000000..263b6963 --- /dev/null +++ b/test/tm-cases/html_classes_is_none.tags @@ -0,0 +1 @@ +extras html-classes diff --git a/test/tm-cases/html_classes_is_none.text b/test/tm-cases/html_classes_is_none.text new file mode 100644 index 00000000..880f0d1a --- /dev/null +++ b/test/tm-cases/html_classes_is_none.text @@ -0,0 +1,3 @@ +``` +print("hello world") +``` \ No newline at end of file diff --git a/test/tm-cases/img_alt_text.html b/test/tm-cases/img_alt_text.html new file mode 100644 index 00000000..dd02a795 --- /dev/null +++ b/test/tm-cases/img_alt_text.html @@ -0,0 +1 @@ +

      a*b*c

      diff --git a/test/tm-cases/img_alt_text.text b/test/tm-cases/img_alt_text.text new file mode 100644 index 00000000..10ddfe77 --- /dev/null +++ b/test/tm-cases/img_alt_text.text @@ -0,0 +1 @@ +![a*b*c](d) diff --git a/test/tm-cases/inline_code_pipe_within_table.html b/test/tm-cases/inline_code_pipe_within_table.html new file mode 100644 index 00000000..547bba44 --- /dev/null +++ b/test/tm-cases/inline_code_pipe_within_table.html @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + +
      SignOperator nameDescription
      &Bitwise andBitwise and between two integer values
      |Bitwise orBitwise or between two integer values
      diff --git a/test/tm-cases/inline_code_pipe_within_table.opts b/test/tm-cases/inline_code_pipe_within_table.opts new file mode 100644 index 00000000..9625694e --- /dev/null +++ b/test/tm-cases/inline_code_pipe_within_table.opts @@ -0,0 +1 @@ +{"extras": ["tables"]} \ No newline at end of file diff --git a/test/tm-cases/inline_code_pipe_within_table.tags b/test/tm-cases/inline_code_pipe_within_table.tags new file mode 100644 index 00000000..8a4af592 --- /dev/null +++ b/test/tm-cases/inline_code_pipe_within_table.tags @@ -0,0 +1 @@ +extra tables \ No newline at end of file diff --git a/test/tm-cases/inline_code_pipe_within_table.text b/test/tm-cases/inline_code_pipe_within_table.text new file mode 100644 index 00000000..f1e8aa26 --- /dev/null +++ b/test/tm-cases/inline_code_pipe_within_table.text @@ -0,0 +1,4 @@ +| Sign | Operator name | Description | +|---|---|---| +| `&` | Bitwise and | Bitwise and between two integer values | +| `|` | Bitwise or | Bitwise or between two integer values | \ No newline at end of file diff --git a/test/tm-cases/inline_links.html b/test/tm-cases/inline_links.html index 431e7f1c..467c0cc6 100644 --- a/test/tm-cases/inline_links.html +++ b/test/tm-cases/inline_links.html @@ -7,3 +7,9 @@

      an inline image link

      an image "with" title

      + +

      [Link in square brackets]

      + +

      [Previous] - [Next]

      + +

      (Link in brackets)

      diff --git a/test/tm-cases/inline_links.text b/test/tm-cases/inline_links.text index e1f48d59..b86b16e8 100644 --- a/test/tm-cases/inline_links.text +++ b/test/tm-cases/inline_links.text @@ -7,3 +7,9 @@ an inline [link with `code`](/url/) an inline ![image link](/url/) an ![image "with" title](/url/ "title") + +[[Link in square brackets](#page)] + +[[Previous](/page1)] - [[Next](/page3)] + +([Link in brackets](#page)) diff --git a/test/tm-cases/issue276_fenced_code_blocks_in_lists.html b/test/tm-cases/issue276_fenced_code_blocks_in_lists.html new file mode 100644 index 00000000..7154404c --- /dev/null +++ b/test/tm-cases/issue276_fenced_code_blocks_in_lists.html @@ -0,0 +1,23 @@ +
        +
      1. This is my first list item

        + +
        And this is my code item
        +
        + +

        Followed by another paragraph

      2. +
      3. This is my second list item

        + +
        
        +
        + +

        empty codeblock just for sh*ts and giggles

        + +
        +
        test with language set
        +
        +
        + +
        This is a regular code block
        +Multiline
        +
      4. +
      diff --git a/test/tm-cases/issue276_fenced_code_blocks_in_lists.opts b/test/tm-cases/issue276_fenced_code_blocks_in_lists.opts new file mode 100644 index 00000000..ba411ac7 --- /dev/null +++ b/test/tm-cases/issue276_fenced_code_blocks_in_lists.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} diff --git a/test/tm-cases/issue276_fenced_code_blocks_in_lists.tags b/test/tm-cases/issue276_fenced_code_blocks_in_lists.tags new file mode 100644 index 00000000..12bca88c --- /dev/null +++ b/test/tm-cases/issue276_fenced_code_blocks_in_lists.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments \ No newline at end of file diff --git a/test/tm-cases/issue276_fenced_code_blocks_in_lists.text b/test/tm-cases/issue276_fenced_code_blocks_in_lists.text new file mode 100644 index 00000000..2a9e5215 --- /dev/null +++ b/test/tm-cases/issue276_fenced_code_blocks_in_lists.text @@ -0,0 +1,21 @@ +1. This is my first list item + + ``` + And this is my code item + ``` + + Followed by another paragraph + +2. This is my second list item + + ``` + ``` + + empty codeblock just for sh\*ts and giggles + + ```python + test with language set + ``` + + This is a regular code block + Multiline \ No newline at end of file diff --git a/test/tm-cases/issue341_xss.html b/test/tm-cases/issue341_xss.html new file mode 100644 index 00000000..1f00d20e --- /dev/null +++ b/test/tm-cases/issue341_xss.html @@ -0,0 +1,5 @@ +

      Example 1: +<ftp:[HTML_REMOVED]alert(1);//><ftp:[HTML_REMOVED]>

      + +

      Example 2: +<http://g[HTML_REMOVED]alert(1);/\*->a><http://ga\\*/[HTML_REMOVED]alert(1);/*->a>

      diff --git a/test/tm-cases/issue341_xss.opts b/test/tm-cases/issue341_xss.opts new file mode 100644 index 00000000..fd31b4e3 --- /dev/null +++ b/test/tm-cases/issue341_xss.opts @@ -0,0 +1 @@ +{"safe_mode": "replace"} diff --git a/test/tm-cases/issue341_xss.text b/test/tm-cases/issue341_xss.text new file mode 100644 index 00000000..8707ce23 --- /dev/null +++ b/test/tm-cases/issue341_xss.text @@ -0,0 +1,5 @@ +Example 1: +alert(1);//]()>]()> + +Example 2: +alert(1);/\*](http://g)->a>alert(1);/*](http://g)->a> \ No newline at end of file diff --git a/test/tm-cases/issue348_incomplete_tag.html b/test/tm-cases/issue348_incomplete_tag.html new file mode 100644 index 00000000..46059cc6 --- /dev/null +++ b/test/tm-cases/issue348_incomplete_tag.html @@ -0,0 +1 @@ +

      <lol@/ //id="pwn"//onclick="alert(1)"//abc

      diff --git a/test/tm-cases/issue348_incomplete_tag.opts b/test/tm-cases/issue348_incomplete_tag.opts new file mode 100644 index 00000000..ad487c04 --- /dev/null +++ b/test/tm-cases/issue348_incomplete_tag.opts @@ -0,0 +1 @@ +{"safe_mode": "escape"} diff --git a/test/tm-cases/issue348_incomplete_tag.text b/test/tm-cases/issue348_incomplete_tag.text new file mode 100644 index 00000000..bb4a0de6 --- /dev/null +++ b/test/tm-cases/issue348_incomplete_tag.text @@ -0,0 +1 @@ + - -

      заголовок

      - -

      Example from http://code.google.com/p/python-markdown2/issues/detail?id=3#c8.

      - -

      Some python code:

      - -
      # комментарий
      -if True:
      -    print "hi"
      -
      diff --git a/test/tm-cases/issue3_bad_code_color_hack.opts b/test/tm-cases/issue3_bad_code_color_hack.opts deleted file mode 100644 index 95dfd418..00000000 --- a/test/tm-cases/issue3_bad_code_color_hack.opts +++ /dev/null @@ -1 +0,0 @@ -{"extras": ["code-color"]} diff --git a/test/tm-cases/issue3_bad_code_color_hack.tags b/test/tm-cases/issue3_bad_code_color_hack.tags deleted file mode 100644 index c3f18a97..00000000 --- a/test/tm-cases/issue3_bad_code_color_hack.tags +++ /dev/null @@ -1 +0,0 @@ -extra code-color unicode pygments issue3 diff --git a/test/tm-cases/issue3_bad_code_color_hack.text b/test/tm-cases/issue3_bad_code_color_hack.text deleted file mode 100644 index e6163a11..00000000 --- a/test/tm-cases/issue3_bad_code_color_hack.text +++ /dev/null @@ -1,12 +0,0 @@ - - -## заголовок - -Example from . - -Some python code: - - :::python - # комментарий - if True: - print "hi" \ No newline at end of file diff --git a/test/tm-cases/issue583_xss.html b/test/tm-cases/issue583_xss.html new file mode 100644 index 00000000..151aadfc --- /dev/null +++ b/test/tm-cases/issue583_xss.html @@ -0,0 +1 @@ +

      <img onerror=alert("hi")[HTML_REMOVED] src=a

      diff --git a/test/tm-cases/issue583_xss.opts b/test/tm-cases/issue583_xss.opts new file mode 100644 index 00000000..3b1054ea --- /dev/null +++ b/test/tm-cases/issue583_xss.opts @@ -0,0 +1 @@ +{'safe_mode': 'replace'} diff --git a/test/tm-cases/issue583_xss.text b/test/tm-cases/issue583_xss.text new file mode 100644 index 00000000..8d3d8472 --- /dev/null +++ b/test/tm-cases/issue583_xss.text @@ -0,0 +1 @@ + src=a diff --git a/test/tm-cases/issue601_xss.html b/test/tm-cases/issue601_xss.html new file mode 100644 index 00000000..e369d54e --- /dev/null +++ b/test/tm-cases/issue601_xss.html @@ -0,0 +1 @@ +

      <img src=# onerror="alert()"></p>

      diff --git a/test/tm-cases/issue601_xss.opts b/test/tm-cases/issue601_xss.opts new file mode 100644 index 00000000..ad487c04 --- /dev/null +++ b/test/tm-cases/issue601_xss.opts @@ -0,0 +1 @@ +{"safe_mode": "escape"} diff --git a/test/tm-cases/issue601_xss.text b/test/tm-cases/issue601_xss.text new file mode 100644 index 00000000..3d584a21 --- /dev/null +++ b/test/tm-cases/issue601_xss.text @@ -0,0 +1 @@ +

      diff --git a/test/tm-cases/issue603_xss.html b/test/tm-cases/issue603_xss.html new file mode 100644 index 00000000..2293d586 --- /dev/null +++ b/test/tm-cases/issue603_xss.html @@ -0,0 +1,6 @@ +

      + +

      + + +

      diff --git a/test/tm-cases/issue603_xss.opts b/test/tm-cases/issue603_xss.opts new file mode 100644 index 00000000..ad487c04 --- /dev/null +++ b/test/tm-cases/issue603_xss.opts @@ -0,0 +1 @@ +{"safe_mode": "escape"} diff --git a/test/tm-cases/issue603_xss.text b/test/tm-cases/issue603_xss.text new file mode 100644 index 00000000..85835be0 --- /dev/null +++ b/test/tm-cases/issue603_xss.text @@ -0,0 +1,12 @@ +![](`" onerror=alert()//`) + + +![][XSS] +[][XSS] +![][XSS2] +![][XSS3] + + +[XSS]: " onerror=alert()// +[XSS2]: `" onerror=alert()//` +[XSS3]: " onerror=alert()// diff --git a/test/tm-cases/latex.html b/test/tm-cases/latex.html new file mode 100644 index 00000000..b91fd4b9 --- /dev/null +++ b/test/tm-cases/latex.html @@ -0,0 +1,18 @@ +

      Simple Test

      + +

      Inline Equations can be written as y=mx+b. +Block equations are wrapped using

      + +x=b±b24ac2a + +

      This code block will not have the math rendered. + +some random code, describing $a and $b will not be rendered, $y=mx$ + +This will not work either $\sqrt{2} or

      + +

      +$$ +f = 12 +$$ +

      diff --git a/test/tm-cases/latex.opts b/test/tm-cases/latex.opts new file mode 100644 index 00000000..627b9f1f --- /dev/null +++ b/test/tm-cases/latex.opts @@ -0,0 +1 @@ +{"extras": ["latex","latex2mathml"]} \ No newline at end of file diff --git a/test/tm-cases/latex.tags b/test/tm-cases/latex.tags new file mode 100644 index 00000000..b39d550d --- /dev/null +++ b/test/tm-cases/latex.tags @@ -0,0 +1 @@ +extra latex latex2mathml \ No newline at end of file diff --git a/test/tm-cases/latex.text b/test/tm-cases/latex.text new file mode 100644 index 00000000..92a9bf29 --- /dev/null +++ b/test/tm-cases/latex.text @@ -0,0 +1,17 @@ +## Simple Test +Inline Equations can be written as $y=mx+b$. +Block equations are wrapped using +$$ +x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a} +$$ +This code block will not have the math rendered. +``` +some random code, describing $a and $b will not be rendered, $y=mx$ +``` +This will not work either `$\sqrt{2}` or + +``` +$$ +f = 12 +$$ +``` \ No newline at end of file diff --git a/test/tm-cases/link_after_square_brackets.html b/test/tm-cases/link_after_square_brackets.html new file mode 100644 index 00000000..a5421f3c --- /dev/null +++ b/test/tm-cases/link_after_square_brackets.html @@ -0,0 +1,3 @@ +

      [before] +Some link +[after]

      diff --git a/test/tm-cases/link_after_square_brackets.text b/test/tm-cases/link_after_square_brackets.text new file mode 100644 index 00000000..7c569d7b --- /dev/null +++ b/test/tm-cases/link_after_square_brackets.text @@ -0,0 +1,3 @@ +[before] +[Some link](https://google.com) +[after] diff --git a/test/tm-cases/link_patterns.opts b/test/tm-cases/link_patterns.opts index 440d5a6d..346d99f4 100644 --- a/test/tm-cases/link_patterns.opts +++ b/test/tm-cases/link_patterns.opts @@ -1,8 +1,7 @@ {"extras": ["link-patterns"], "link_patterns": [ - (re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), - (re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), - (re.compile("PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))), + (re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), + (re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), + (re.compile(r"PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))), ], } - diff --git a/test/tm-cases/link_patterns_double_hit.opts b/test/tm-cases/link_patterns_double_hit.opts index d64982d8..563952fd 100644 --- a/test/tm-cases/link_patterns_double_hit.opts +++ b/test/tm-cases/link_patterns_double_hit.opts @@ -1,7 +1,6 @@ {"extras": ["link-patterns"], "link_patterns": [ (re.compile(r'mozilla\s+bug\s+(\d+)', re.I), r'http://bugzilla.mozilla.org/show_bug.cgi?id=\1'), - (re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), + (re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), ], } - diff --git a/test/tm-cases/link_patterns_edge_cases.html b/test/tm-cases/link_patterns_edge_cases.html index ffd0a72e..15dc258f 100644 --- a/test/tm-cases/link_patterns_edge_cases.html +++ b/test/tm-cases/link_patterns_edge_cases.html @@ -1 +1,5 @@

      Blah 123 becomes a line with two underscores.

      + +

      http://localhost/#42 with another reference to Issue #42 in the same line

      + +

      Issue #42

      diff --git a/test/tm-cases/link_patterns_edge_cases.opts b/test/tm-cases/link_patterns_edge_cases.opts index 99ce0f79..39235f28 100644 --- a/test/tm-cases/link_patterns_edge_cases.opts +++ b/test/tm-cases/link_patterns_edge_cases.opts @@ -1,6 +1,6 @@ {"extras": ["link-patterns"], "link_patterns": [ - (re.compile("Blah\s+(\d+)", re.I), r"http://foo.com/blah_blah_blah//1"), + (re.compile(r"Blah\s+(\d+)", re.I), r"http://foo.com/blah_blah_blah//1"), + (re.compile("#([1-9][0-9]*)"), r"http://localhost/issue//1"), ], } - diff --git a/test/tm-cases/link_patterns_edge_cases.text b/test/tm-cases/link_patterns_edge_cases.text index d1fb62cf..2e2943ee 100644 --- a/test/tm-cases/link_patterns_edge_cases.text +++ b/test/tm-cases/link_patterns_edge_cases.text @@ -1 +1,5 @@ Blah 123 becomes a line with two underscores. + + with another reference to Issue #42 in the same line + +[Issue #42](http://localhost) \ No newline at end of file diff --git a/test/tm-cases/link_patterns_escape.opts b/test/tm-cases/link_patterns_escape.opts index 440d5a6d..346d99f4 100644 --- a/test/tm-cases/link_patterns_escape.opts +++ b/test/tm-cases/link_patterns_escape.opts @@ -1,8 +1,7 @@ {"extras": ["link-patterns"], "link_patterns": [ - (re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), - (re.compile("(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), - (re.compile("PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))), + (re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), + (re.compile(r"(?:komodo\s+)?bug\s+(\d+)", re.I), r"http://bugs.activestate.com/show_bug.cgi?id=\1"), + (re.compile(r"PEP\s+(\d+)", re.I), lambda m: "http://www.python.org/dev/peps/pep-%04d/" % int(m.group(1))), ], } - diff --git a/test/tm-cases/link_patterns_hash_matching_issue287.html b/test/tm-cases/link_patterns_hash_matching_issue287.html new file mode 100644 index 00000000..7cee86e2 --- /dev/null +++ b/test/tm-cases/link_patterns_hash_matching_issue287.html @@ -0,0 +1 @@ +

      this is a test issue #1234 with a test commit (addeddd) made by test @username more text

      diff --git a/test/tm-cases/link_patterns_hash_matching_issue287.opts b/test/tm-cases/link_patterns_hash_matching_issue287.opts new file mode 100644 index 00000000..2c8e3b33 --- /dev/null +++ b/test/tm-cases/link_patterns_hash_matching_issue287.opts @@ -0,0 +1,7 @@ +{"extras": ["link-patterns"], + "link_patterns": [ + (re.compile(r"#(\d+)", re.I), r"https://github.com/pyfa-org/Pyfa/issues//1"), + (re.compile(r"@(\w+)", re.I), r"https://github.com//1"), + (re.compile("([0-9a-f]{6,40})", re.I), r"https://github.com/pyfa-org/Pyfa/commit//1") + ] +} diff --git a/test/tm-cases/link_patterns_hash_matching_issue287.text b/test/tm-cases/link_patterns_hash_matching_issue287.text new file mode 100644 index 00000000..b0b5f4b9 --- /dev/null +++ b/test/tm-cases/link_patterns_hash_matching_issue287.text @@ -0,0 +1 @@ +this is a test issue #1234 with a test commit (addeddd) made by test @username more text diff --git a/test/tm-cases/link_patterns_markdown_syntax.opts b/test/tm-cases/link_patterns_markdown_syntax.opts index f33b27ee..2c8a9047 100644 --- a/test/tm-cases/link_patterns_markdown_syntax.opts +++ b/test/tm-cases/link_patterns_markdown_syntax.opts @@ -1,5 +1,5 @@ {"extras": ["link-patterns"], "link_patterns": [ - (re.compile("recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), + (re.compile(r"recipe\s+(\d+)", re.I), r"http://code.activestate.com/recipes//1/"), ], -} \ No newline at end of file +} diff --git a/test/tm-cases/link_safe_urls.html b/test/tm-cases/link_safe_urls.html index d1ac0d3a..b035827b 100644 --- a/test/tm-cases/link_safe_urls.html +++ b/test/tm-cases/link_safe_urls.html @@ -1,11 +1,47 @@ +

      Normal links

      +

      Safe link 1

      Safe link 2

      Safe link 3

      -

      Safe link 4

      +

      Safe link 4

      + +

      Safe link 5

      + +

      Safe link 6

      + +

      Bad protocols

      Unsafe link 1

      Unsafe link 2

      + +

      Relative links

      + +

      Safe link 1

      + +

      Safe link 2

      + +

      Safe link 3

      + +

      Safe link 4

      + +

      Unsafe link 1

      + +

      Edge cases

      + +

      Safe link 1

      + +

      Safe link 2

      + +

      Safe link 3

      + +

      Safe link 4

      + +

      Unsafe link 1

      + +

      Unsafe link 2

      + +

      Unsafe link 3

      diff --git a/test/tm-cases/link_safe_urls.text b/test/tm-cases/link_safe_urls.text index 56a21fad..88230460 100644 --- a/test/tm-cases/link_safe_urls.text +++ b/test/tm-cases/link_safe_urls.text @@ -1,11 +1,47 @@ +# Normal links + [Safe link 1](https://www.example.com) [Safe link 2](http://www.example.com) [Safe link 3](ftp://www.example.com) -[Safe link 4](#anchor) +[Safe link 4](mailto:emailaddress@server.com) + +[Safe link 5](tel:0123456789) + +[Safe link 6](#anchor) + +# Bad protocols [Unsafe link 1](unknown://www.example.com) -[Unsafe link 2](example) +[Unsafe link 2](mailfrom:www.example.com) + +# Relative links + +[Safe link 1](example) + +[Safe link 2](./example) + +[Safe link 3](../../example) + +[Safe link 4](/example) + +[Unsafe link 1](.../www.example.com) + +# Edge cases + +[Safe link 1](www.example.com/abc:def) + +[Safe link 2](www.example.com/abc:/def) + +[Safe link 3](https://www.example.com:4200) + +[Safe link 4](https://www.example.com:4200/abcdef) + +[Unsafe link 1](unknown://www.example.com://abc) + +[Unsafe link 2](C:/Windows/System32) + +[Unsafe link 3](C:\Windows\System32) diff --git a/test/tm-cases/link_shortrefs.html b/test/tm-cases/link_shortrefs.html new file mode 100644 index 00000000..02824ce5 --- /dev/null +++ b/test/tm-cases/link_shortrefs.html @@ -0,0 +1,11 @@ +

      Python

      + +

      abc Python def

      + +

      Pythons

      + +

      Python

      + +

      Pythonwithmoretext

      + +

      [NoLink]

      diff --git a/test/tm-cases/link_shortrefs.opts b/test/tm-cases/link_shortrefs.opts new file mode 100644 index 00000000..5e139454 --- /dev/null +++ b/test/tm-cases/link_shortrefs.opts @@ -0,0 +1 @@ +{"extras": ["link-shortrefs"]} diff --git a/test/tm-cases/link_shortrefs.tags b/test/tm-cases/link_shortrefs.tags new file mode 100644 index 00000000..c922086f --- /dev/null +++ b/test/tm-cases/link_shortrefs.tags @@ -0,0 +1 @@ +extras link-shortrefs diff --git a/test/tm-cases/link_shortrefs.text b/test/tm-cases/link_shortrefs.text new file mode 100644 index 00000000..c7c1adbf --- /dev/null +++ b/test/tm-cases/link_shortrefs.text @@ -0,0 +1,13 @@ +[Python] + +abc [Python] def + +[Python]s + +[Python][] + +[Python]with_more_text + +[NoLink] + +[Python]: https://www.python.org diff --git a/test/tm-cases/link_with_blank.html b/test/tm-cases/link_with_blank.html index 0d6e1dfe..df2c0037 100644 --- a/test/tm-cases/link_with_blank.html +++ b/test/tm-cases/link_with_blank.html @@ -1,5 +1,5 @@ -

      Ref

      +

      Ref

      Foo

      -

      One

      +

      One

      diff --git a/test/tm-cases/link_with_blank_nofollow.html b/test/tm-cases/link_with_blank_nofollow.html new file mode 100644 index 00000000..a982dfd0 --- /dev/null +++ b/test/tm-cases/link_with_blank_nofollow.html @@ -0,0 +1,5 @@ +

      Ref

      + +

      Foo

      + +

      One

      diff --git a/test/tm-cases/link_with_blank_nofollow.opts b/test/tm-cases/link_with_blank_nofollow.opts new file mode 100644 index 00000000..f1d661fd --- /dev/null +++ b/test/tm-cases/link_with_blank_nofollow.opts @@ -0,0 +1 @@ +{"extras": ["target-blank-links", "nofollow"]} diff --git a/test/tm-cases/link_with_blank_nofollow.tags b/test/tm-cases/link_with_blank_nofollow.tags new file mode 100644 index 00000000..b72d7a3b --- /dev/null +++ b/test/tm-cases/link_with_blank_nofollow.tags @@ -0,0 +1 @@ +extras nofollow blank diff --git a/test/tm-cases/link_with_blank_nofollow.text b/test/tm-cases/link_with_blank_nofollow.text new file mode 100644 index 00000000..1acd167c --- /dev/null +++ b/test/tm-cases/link_with_blank_nofollow.text @@ -0,0 +1,5 @@ +[Ref](http://www.example.com) + +[Foo](#bar) + +[One](http://www.example.com/two#three) diff --git a/test/tm-cases/lists3.html b/test/tm-cases/lists3.html new file mode 100644 index 00000000..35dd3424 --- /dev/null +++ b/test/tm-cases/lists3.html @@ -0,0 +1,79 @@ +

      Single list tight:

      + +
        +
      • hi
      • +
      • there
      • +
      • fella
      • +
      + +

      Single list loose in "paragraph mode":

      + +
        +
      • hey

      • +
      • there

      • +
      • partner

      • +
      + +

      Single list loose with multiple paragraphs in an item:

      + +
        +
      • How you doin'?

      • +
      • this item contains multiple paragraphs.

        + +

        More than one that is.

        + +

        Three to be exact.

      • +
      • And this one is just a bunch of lines. +Spliced together as a single item. +A single paragraph.

      • +
      + +

      A single list that looks like multiple lists +separated by a blank line:

      + +
        +
      • list 1
      • +
      • with three
      • +
      • elements

      • +
      • still list 1

      • +
      • adding four
      • +
      • more
      • +
      • elements

      • +
      • sic, this is still list 1

      • +
      • now with
      • +
      • even
      • +
      • more
      • +
      • elements
      • +
      + +

      There's no way to actually get multiple consecutive lists in Markdown. +Neither Markdown.pl nor python-markdown allow it either. +In a mailing list thread a few years back, John Gruber +suggested using double blank lines +to separate consecutive lists but no implementation does it. +For now you need to separate consecutive lists with unindented text:

      + +
        +
      • list 1
      • +
      • with three
      • +
      • elements
      • +
      + +

      Cough.

      + +
        +
      • list 2
      • +
      • with
      • +
      • four
      • +
      • elements
      • +
      + +

      Cough. Cough.

      + +
        +
      • list 3
      • +
      • with
      • +
      • even
      • +
      • more
      • +
      • elements
      • +
      diff --git a/test/tm-cases/lists3.tags b/test/tm-cases/lists3.tags new file mode 100644 index 00000000..3bba0578 --- /dev/null +++ b/test/tm-cases/lists3.tags @@ -0,0 +1 @@ +issue313 \ No newline at end of file diff --git a/test/tm-cases/lists3.text b/test/tm-cases/lists3.text new file mode 100644 index 00000000..410261be --- /dev/null +++ b/test/tm-cases/lists3.text @@ -0,0 +1,71 @@ +Single list tight: + +* hi +* there +* fella + +Single list loose in "paragraph mode": + +* hey + +* there + +* partner + +Single list loose with multiple paragraphs in an item: + +* How you doin'? + +* this item contains multiple paragraphs. + + More than one that is. + + Three to be exact. + +* And this one is just a bunch of lines. + Spliced together as a single item. + A single paragraph. + +A single list that looks like multiple lists +separated by a blank line: + +* list 1 +* with three +* elements + +* still list 1 +* adding four +* more +* elements + +* sic, this is still list 1 +* now with +* even +* more +* elements + +There's no way to actually get multiple consecutive lists in Markdown. +Neither Markdown.pl nor python-markdown allow it either. +In a mailing list thread a few years back, John Gruber +[suggested using double blank lines](https://web.archive.org/web/20181229032814/http://article.gmane.org:80/gmane.text.markdown.general/2554) +to separate consecutive lists but no implementation does it. +For now you need to separate consecutive lists with unindented text: + +* list 1 +* with three +* elements + +Cough. + +* list 2 +* with +* four +* elements + +Cough. Cough. + +* list 3 +* with +* even +* more +* elements diff --git a/test/tm-cases/malformed_html_crash_issue584.html b/test/tm-cases/malformed_html_crash_issue584.html new file mode 100644 index 00000000..e2071f84 --- /dev/null +++ b/test/tm-cases/malformed_html_crash_issue584.html @@ -0,0 +1,3 @@ +

      +
      diff --git a/test/tm-cases/malformed_html_crash_issue584.text b/test/tm-cases/malformed_html_crash_issue584.text
      new file mode 100644
      index 00000000..e2071f84
      --- /dev/null
      +++ b/test/tm-cases/malformed_html_crash_issue584.text
      @@ -0,0 +1,3 @@
      +

      +
      diff --git a/test/tm-cases/markdown_file_links.html b/test/tm-cases/markdown_file_links.html
      new file mode 100644
      index 00000000..916e2fea
      --- /dev/null
      +++ b/test/tm-cases/markdown_file_links.html
      @@ -0,0 +1,3 @@
      +

      This is a link to a markdown file

      + +

      This is a reference to a markdown file link

      diff --git a/test/tm-cases/markdown_file_links.opts b/test/tm-cases/markdown_file_links.opts new file mode 100644 index 00000000..e1d066da --- /dev/null +++ b/test/tm-cases/markdown_file_links.opts @@ -0,0 +1 @@ +{'extras': ['markdown-file-links']} \ No newline at end of file diff --git a/test/tm-cases/markdown_file_links.text b/test/tm-cases/markdown_file_links.text new file mode 100644 index 00000000..456340a9 --- /dev/null +++ b/test/tm-cases/markdown_file_links.text @@ -0,0 +1,6 @@ +[This is a link to a markdown file](./file.md) + +[This is a reference to a markdown file link][] + + +[This is a reference to a markdown file link]: ./something.md diff --git a/test/tm-cases/markdown_file_links_no_linkdefs.html b/test/tm-cases/markdown_file_links_no_linkdefs.html new file mode 100644 index 00000000..48f897df --- /dev/null +++ b/test/tm-cases/markdown_file_links_no_linkdefs.html @@ -0,0 +1 @@ +

      This is a reference to a markdown file link but link definition swapping is disabled

      diff --git a/test/tm-cases/markdown_file_links_no_linkdefs.opts b/test/tm-cases/markdown_file_links_no_linkdefs.opts new file mode 100644 index 00000000..c5ae83b5 --- /dev/null +++ b/test/tm-cases/markdown_file_links_no_linkdefs.opts @@ -0,0 +1 @@ +{'extras': {'markdown-file-links': {'link_defs': False}}} \ No newline at end of file diff --git a/test/tm-cases/markdown_file_links_no_linkdefs.text b/test/tm-cases/markdown_file_links_no_linkdefs.text new file mode 100644 index 00000000..6715929d --- /dev/null +++ b/test/tm-cases/markdown_file_links_no_linkdefs.text @@ -0,0 +1,4 @@ +[This is a reference to a markdown file link][] but link definition swapping is disabled + + +[This is a reference to a markdown file link]: ./something.md diff --git a/test/tm-cases/markdown_in_html_in_lists.html b/test/tm-cases/markdown_in_html_in_lists.html new file mode 100644 index 00000000..18ae6bf3 --- /dev/null +++ b/test/tm-cases/markdown_in_html_in_lists.html @@ -0,0 +1,53 @@ +
        +
      • Item 1

        + +
        + +
        Block one
        + +

        Some text

        + +
      • +
      • Item 2

        + +
          +
        • Item 3

          + +
            +
          • Item 4

            + +
            + +
            Block two
            + +

            Some text

            + +
          • +
        • +
        • Item 5

          + +
          + +
          Block three
          + +

          Some text

          + +
        • +
      • + + +
      • one two

        + +

        + +

        NOTE: opening tag is slightly indented

        + +

      • +
      • three four

        + +

        + +

        NOTE: both tags are slightly indented

        + +

      • +
      diff --git a/test/tm-cases/markdown_in_html_in_lists.opts b/test/tm-cases/markdown_in_html_in_lists.opts new file mode 100644 index 00000000..25fea79f --- /dev/null +++ b/test/tm-cases/markdown_in_html_in_lists.opts @@ -0,0 +1 @@ +{"extras": ["markdown-in-html"]} diff --git a/test/tm-cases/markdown_in_html_in_lists.text b/test/tm-cases/markdown_in_html_in_lists.text new file mode 100644 index 00000000..22121126 --- /dev/null +++ b/test/tm-cases/markdown_in_html_in_lists.text @@ -0,0 +1,28 @@ +- Item 1 +
      + ###### Block one + Some text +
      +- Item 2 + - Item 3 + - Item 4 +
      + ###### Block two + Some text +
      + - Item 5 +
      + ###### Block three + Some text +
      + + + +- one two +

      + *NOTE:* opening tag is slightly indented +

      +- three four +

      + *NOTE:* both tags are slightly indented +

      diff --git a/test/tm-cases/markdown_in_html_on_same_line.html b/test/tm-cases/markdown_in_html_on_same_line.html new file mode 100644 index 00000000..2c220974 --- /dev/null +++ b/test/tm-cases/markdown_in_html_on_same_line.html @@ -0,0 +1,40 @@ +

      + +

      text

      + +

      + +

      + +

      text

      + +

      + +

      + +

      text

      + +

      + +

      + +

      text

      + +

      + +

      + +

      text +text +text

      + +

      + +

      + +

      text +text +text +text

      + +

      diff --git a/test/tm-cases/markdown_in_html_on_same_line.opts b/test/tm-cases/markdown_in_html_on_same_line.opts new file mode 100644 index 00000000..25fea79f --- /dev/null +++ b/test/tm-cases/markdown_in_html_on_same_line.opts @@ -0,0 +1 @@ +{"extras": ["markdown-in-html"]} diff --git a/test/tm-cases/markdown_in_html_on_same_line.text b/test/tm-cases/markdown_in_html_on_same_line.text new file mode 100644 index 00000000..80143618 --- /dev/null +++ b/test/tm-cases/markdown_in_html_on_same_line.text @@ -0,0 +1,22 @@ +

      **text**

      + + +

      +**text**

      + +

      **text** +

      + +

      +**text** +

      + +

      **text** +**text** +**text** +

      + +

      **text** +**text** +**text** +**text**

      diff --git a/test/tm-cases/mermaid.html b/test/tm-cases/mermaid.html new file mode 100644 index 00000000..257882f1 --- /dev/null +++ b/test/tm-cases/mermaid.html @@ -0,0 +1,13 @@ +

      This is a sample workflow

      + +
      graph LR + A-->B + A-->C + C-->E + B-->D + C-->D + D-->F + E-->F +
      + +

      left-right type mermaid graph.

      diff --git a/test/tm-cases/mermaid.opts b/test/tm-cases/mermaid.opts new file mode 100644 index 00000000..fb557ac2 --- /dev/null +++ b/test/tm-cases/mermaid.opts @@ -0,0 +1 @@ +{"extras": ['mermaid']} diff --git a/test/tm-cases/mermaid.tags b/test/tm-cases/mermaid.tags new file mode 100644 index 00000000..fb5eed74 --- /dev/null +++ b/test/tm-cases/mermaid.tags @@ -0,0 +1 @@ +extras mermaid diff --git a/test/tm-cases/mermaid.text b/test/tm-cases/mermaid.text new file mode 100644 index 00000000..37c61c98 --- /dev/null +++ b/test/tm-cases/mermaid.text @@ -0,0 +1,15 @@ +This is a sample workflow + +```mermaid +graph LR + A-->B + A-->C + C-->E + B-->D + C-->D + D-->F + E-->F +``` + +left-right type mermaid graph. + diff --git a/test/tm-cases/metadata.metadata b/test/tm-cases/metadata.metadata index b1eb9146..a0180539 100644 --- a/test/tm-cases/metadata.metadata +++ b/test/tm-cases/metadata.metadata @@ -4,6 +4,8 @@ "And": "some, cvs, data, which, you, must, parse, yourself", "this-is": "a hyphen test", "empty": "", - "and some": "long value\n that goes multiline", - "another": "example" + "and some": "long value\n with complex indentation\nthat goes multiline", + "another": "example", + "alist": ["a", "b", "c"], + "adict": {"key": "foo", "a nested list": ["one", "two", "Even multiline strings are allowed\n in nested structured data\n if linebreaks and indent are respected !", {"subkey": "and another dict in a list"}, "but one-liners remains: simple strings"]} } diff --git a/test/tm-cases/metadata.text b/test/tm-cases/metadata.text index be68e292..60dc7b15 100644 --- a/test/tm-cases/metadata.text +++ b/test/tm-cases/metadata.text @@ -6,8 +6,25 @@ this-is : a hyphen test empty : and some: > long value + with complex indentation that goes multiline another: example +alist: + - a + - b + - c +adict: + key: foo + a nested list: + - one + - two + - > + Even multiline strings are allowed + in nested structured data + if linebreaks and indent are respected ! + - + subkey: and another dict in a list + - but one-liners remains: simple strings --- # The real text diff --git a/test/tm-cases/metadata2.metadata b/test/tm-cases/metadata2.metadata index 172822d9..3b392f62 100644 --- a/test/tm-cases/metadata2.metadata +++ b/test/tm-cases/metadata2.metadata @@ -4,6 +4,6 @@ "And": "some, cvs, data, which, you, must, parse, yourself", "this-is": "a hyphen test", "empty": "", - "another long": "long value\n that goes multiline", + "another long": "long value\n with complex indentation\nthat goes multiline", "another": "example" } diff --git a/test/tm-cases/metadata2.text b/test/tm-cases/metadata2.text index 13579f12..b59d3121 100644 --- a/test/tm-cases/metadata2.text +++ b/test/tm-cases/metadata2.text @@ -5,6 +5,7 @@ this-is : a hyphen test empty : another long: > long value + with complex indentation that goes multiline another: example diff --git a/test/tm-cases/metadata3.html b/test/tm-cases/metadata3.html new file mode 100644 index 00000000..2b85c958 --- /dev/null +++ b/test/tm-cases/metadata3.html @@ -0,0 +1 @@ +

      This tests various metadata key:value configurations to make sure they will work well consecutively

      diff --git a/test/tm-cases/metadata3.metadata b/test/tm-cases/metadata3.metadata new file mode 100644 index 00000000..f5033d0d --- /dev/null +++ b/test/tm-cases/metadata3.metadata @@ -0,0 +1,26 @@ +{ + "basic": "value", + "basic2": "test consecutive basic keys", + "empty": "", + "empty2": "", + "long-desc": "long multiline\n description\nwith varying levels of\n indentation", + "long-desc2": "test consecutive long descriptions", + "nested": [ + "list item", + "following a long description" + ], + "nested2": [ + "consecutive nested" + ], + "nested3": [ + { + "subkey": "with subkeys" + } + ], + "long-desc3": "long description following a nested", + "empty-following-long-desc": "", + "key with spaces": "will also be recognized", + "-key_start_with_hyphen": "allowed", + "tab indented key": "allowed", + "finish-with": "a nice long description\nover a couple lines" +} diff --git a/test/tm-cases/metadata3.opts b/test/tm-cases/metadata3.opts new file mode 100644 index 00000000..04e37532 --- /dev/null +++ b/test/tm-cases/metadata3.opts @@ -0,0 +1 @@ +{"extras": ["metadata"]} diff --git a/test/tm-cases/metadata3.text b/test/tm-cases/metadata3.text new file mode 100644 index 00000000..e2e12687 --- /dev/null +++ b/test/tm-cases/metadata3.text @@ -0,0 +1,33 @@ +--- + : empty key should be ignored +basic: value +basic2: test consecutive basic keys +empty: +empty2 : +long-desc: > + long multiline + description + with varying levels of + indentation +long-desc2: > + test consecutive long descriptions +nested: + - list item + - following a long description +nested2: + - consecutive nested +nested3: + - + subkey: with subkeys +long-desc3: > + long description following a nested +empty-following-long-desc: +key with spaces: will also be recognized +-key_start_with_hyphen: allowed + tab indented key: allowed +finish-with : > + a nice long description + over a couple lines +--- + +This tests various metadata key:value configurations to make sure they will work well consecutively \ No newline at end of file diff --git a/test/tm-cases/middle_word_em.html b/test/tm-cases/middle_word_em.html new file mode 100644 index 00000000..cc28b9aa --- /dev/null +++ b/test/tm-cases/middle_word_em.html @@ -0,0 +1,5 @@ +

      When middle word emphasis is disabled strings like 'self.this_long_attr' should not +become self.this<em>long</em>attr.

      + +

      Emphasis will only occur when the word is surrounded with whitespace. +This should still work with my_filename.

      diff --git a/test/tm-cases/middle_word_em.opts b/test/tm-cases/middle_word_em.opts new file mode 100644 index 00000000..c69e4954 --- /dev/null +++ b/test/tm-cases/middle_word_em.opts @@ -0,0 +1 @@ +{'extras': {'middle-word-em': False}} diff --git a/test/tm-cases/middle_word_em.text b/test/tm-cases/middle_word_em.text new file mode 100644 index 00000000..96883313 --- /dev/null +++ b/test/tm-cases/middle_word_em.text @@ -0,0 +1,5 @@ +When middle word emphasis is disabled strings like 'self.this_long_attr' should not +become `self.thislongattr`. + +Emphasis will _only_ occur when the word is surrounded with whitespace. +This should still work with _my_filename_. diff --git a/test/tm-cases/middle_word_em_issue627.html b/test/tm-cases/middle_word_em_issue627.html new file mode 100644 index 00000000..66aa95bb --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.html @@ -0,0 +1 @@ +

      abcdefghi

      diff --git a/test/tm-cases/middle_word_em_issue627.opts b/test/tm-cases/middle_word_em_issue627.opts new file mode 100644 index 00000000..47407860 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.opts @@ -0,0 +1 @@ +{'extras': {'middle-word-em': None}} \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue627.text b/test/tm-cases/middle_word_em_issue627.text new file mode 100644 index 00000000..462861e6 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue627.text @@ -0,0 +1 @@ +abc_def_ghi \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue637.html b/test/tm-cases/middle_word_em_issue637.html new file mode 100644 index 00000000..5670b8de --- /dev/null +++ b/test/tm-cases/middle_word_em_issue637.html @@ -0,0 +1,2 @@ +

      Visit GitHub for code repositories and +Stack Overflow for programming help.

      diff --git a/test/tm-cases/middle_word_em_issue637.opts b/test/tm-cases/middle_word_em_issue637.opts new file mode 100644 index 00000000..f1455c41 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue637.opts @@ -0,0 +1 @@ +{'extras': {'middle-word-em': False}} \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue637.text b/test/tm-cases/middle_word_em_issue637.text new file mode 100644 index 00000000..5ca8a0a1 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue637.text @@ -0,0 +1,2 @@ +Visit [**GitHub**](https://github.com) for code repositories and +[**Stack Overflow**](https://stackoverflow.com) for programming help. \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue641.html b/test/tm-cases/middle_word_em_issue641.html new file mode 100644 index 00000000..39886631 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue641.html @@ -0,0 +1,3 @@ +

      Strong (em)

      + +

      note:this is good, but this is not

      diff --git a/test/tm-cases/middle_word_em_issue641.opts b/test/tm-cases/middle_word_em_issue641.opts new file mode 100644 index 00000000..f1455c41 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue641.opts @@ -0,0 +1 @@ +{'extras': {'middle-word-em': False}} \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_issue641.text b/test/tm-cases/middle_word_em_issue641.text new file mode 100644 index 00000000..b14e5d28 --- /dev/null +++ b/test/tm-cases/middle_word_em_issue641.text @@ -0,0 +1,3 @@ +**Strong** (*em*) + +note:*this is good*, but *this is not* \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_with_extra_ems.html b/test/tm-cases/middle_word_em_with_extra_ems.html new file mode 100644 index 00000000..a8974039 --- /dev/null +++ b/test/tm-cases/middle_word_em_with_extra_ems.html @@ -0,0 +1,19 @@ +

      Double variants:

      + +

      one_two_three

      + +

      one_two_three

      + +

      one_two_three

      + +

      one_two_three

      + +

      Single variants:

      + +

      one_two_three

      + +

      one_two_three

      + +

      one*two*three

      + +

      one*two*three

      diff --git a/test/tm-cases/middle_word_em_with_extra_ems.opts b/test/tm-cases/middle_word_em_with_extra_ems.opts new file mode 100644 index 00000000..e318f1bb --- /dev/null +++ b/test/tm-cases/middle_word_em_with_extra_ems.opts @@ -0,0 +1 @@ +{"extras": {"middle-word-em": False}} \ No newline at end of file diff --git a/test/tm-cases/middle_word_em_with_extra_ems.text b/test/tm-cases/middle_word_em_with_extra_ems.text new file mode 100644 index 00000000..4f32e25a --- /dev/null +++ b/test/tm-cases/middle_word_em_with_extra_ems.text @@ -0,0 +1,19 @@ +Double variants: + +**one_two_three** + +***one_two_three*** + +_**one_two_three**_ + +**_one_two_three_** + +Single variants: + +*one_two_three* + +_one_two_three_ + +_one*two*three_ + +*one*two*three* \ No newline at end of file diff --git a/test/tm-cases/mix-ordered-and-unordered-lists.html b/test/tm-cases/mix-ordered-and-unordered-lists.html new file mode 100644 index 00000000..09ece6b4 --- /dev/null +++ b/test/tm-cases/mix-ordered-and-unordered-lists.html @@ -0,0 +1,23 @@ +
        +
      1. Test:
      2. +
      3. Lorem Ipsum
      4. +
      + +
        +
      • Lorem Ipsum
      • +
      • Lorem Ipsum
      • +
      • Lorem Ipsum
      • +
      + +

      And another one

      + +
        +
      1. Test: +Lorem Ipsum
      2. +
      + +
        +
      • Lorem Ipsum
      • +
      • Lorem Ipsum
      • +
      • Lorem Ipsum
      • +
      diff --git a/test/tm-cases/mix-ordered-and-unordered-lists.text b/test/tm-cases/mix-ordered-and-unordered-lists.text new file mode 100644 index 00000000..53a4d03d --- /dev/null +++ b/test/tm-cases/mix-ordered-and-unordered-lists.text @@ -0,0 +1,15 @@ +1. Test: +2. Lorem Ipsum +- Lorem Ipsum +- Lorem Ipsum +- Lorem Ipsum + + +And another one + + +1. Test: +Lorem Ipsum +- Lorem Ipsum +- Lorem Ipsum +- Lorem Ipsum \ No newline at end of file diff --git a/test/tm-cases/mixed_header_ids.html b/test/tm-cases/mixed_header_ids.html new file mode 100644 index 00000000..dfe6cf48 --- /dev/null +++ b/test/tm-cases/mixed_header_ids.html @@ -0,0 +1,11 @@ +

      Header 1

      + +

      Header 2

      + +

      Header 3

      + +

      Header 4

      + +

      Header 5

      + +
      Header 6
      diff --git a/test/tm-cases/mixed_header_ids.opts b/test/tm-cases/mixed_header_ids.opts new file mode 100644 index 00000000..6ee80acb --- /dev/null +++ b/test/tm-cases/mixed_header_ids.opts @@ -0,0 +1 @@ +{"extras": {"header-ids": {"mixed": True}, "toc": None}} diff --git a/test/tm-cases/mixed_header_ids.text b/test/tm-cases/mixed_header_ids.text new file mode 100644 index 00000000..49bb9474 --- /dev/null +++ b/test/tm-cases/mixed_header_ids.text @@ -0,0 +1,11 @@ +# Header 1 + +

      Header 2

      + +# Header 3 + +

      Header 4

      + +# Header 5 + +
      Header 6
      diff --git a/test/tm-cases/mixed_header_ids.toc_html b/test/tm-cases/mixed_header_ids.toc_html new file mode 100644 index 00000000..cd43e647 --- /dev/null +++ b/test/tm-cases/mixed_header_ids.toc_html @@ -0,0 +1,14 @@ + diff --git a/test/tm-cases/nested_incomplete_tags_xss.html b/test/tm-cases/nested_incomplete_tags_xss.html new file mode 100644 index 00000000..bc89c2f3 --- /dev/null +++ b/test/tm-cases/nested_incomplete_tags_xss.html @@ -0,0 +1,7 @@ +

      <img <img src="" onerror=alert(/XSS/)

      + +

      <img<img src="" onerror=alert(/XSS/)

      + +

      <img<img/src="" onerror=alert(/XSS/)

      + +

      <img<img<img src="" onerror=alert(/XSS/)

      diff --git a/test/tm-cases/nested_incomplete_tags_xss.opts b/test/tm-cases/nested_incomplete_tags_xss.opts new file mode 100644 index 00000000..fd31b4e3 --- /dev/null +++ b/test/tm-cases/nested_incomplete_tags_xss.opts @@ -0,0 +1 @@ +{"safe_mode": "replace"} diff --git a/test/tm-cases/nested_incomplete_tags_xss.text b/test/tm-cases/nested_incomplete_tags_xss.text new file mode 100644 index 00000000..4fe21c04 --- /dev/null +++ b/test/tm-cases/nested_incomplete_tags_xss.text @@ -0,0 +1,7 @@ +peaches
+ +

Slightly more nested list:

+ +
    +
  • Item 1 +
      +
    1. Hello
    2. +
    3. World
    4. +
  • +
  • Item 2 +
      +
    • Subitem A
    • +
    • Subitem B following: +
        +
      • What
      • +
      • The
      • +
      • Code
      • +
    • +
  • +
  • Item 3 - yes! just a single item
  • +
+ +

Other more different nested list:

+ +
    +
  • Item 1 +With some space after

  • +
  • Item 2

    + +
      +
    • Item 3 +
        +
      • Item 4
      • +
    • +
  • +
diff --git a/test/tm-cases/nested_list.text b/test/tm-cases/nested_list.text index a37a1954..14fb9291 100644 --- a/test/tm-cases/nested_list.text +++ b/test/tm-cases/nested_list.text @@ -7,3 +7,27 @@ shopping list: + oranges + apples + *peaches* + + +Slightly more nested list: + +* Item 1 + 1. Hello + 2. World +* Item 2 + - Subitem A + - Subitem B following: + + What + + The + + Code +* Item 3 - yes! just a single item + + +Other more different nested list: + +- Item 1 + With some space after + +- Item 2 + - Item 3 + - Item 4 diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.html b/test/tm-cases/not_quite_a_list_cuddled_lists.html new file mode 100644 index 00000000..0a675da4 --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.html @@ -0,0 +1,26 @@ +

So:

+ +
    +
  • This
  • +
  • is
  • +
  • a list.
  • +
+ +

And:

+ +
    +
  • This is
  • +
  • a list
  • +
  • too.
  • +
+ +

However, because ASCII art can have long dash/asterisk lines let ensure that:

+ +

- - - - - - - This isn't a list.

+ +

* * Nor is this a list. +- - - Or this.

+ +

- - - - - - - - - - + + hi there ascii art +- - - - - - - - - - +

diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.opts b/test/tm-cases/not_quite_a_list_cuddled_lists.opts new file mode 100644 index 00000000..697d1301 --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.opts @@ -0,0 +1 @@ +{"extras": ["cuddled-lists"]} \ No newline at end of file diff --git a/test/tm-cases/not_quite_a_list_cuddled_lists.text b/test/tm-cases/not_quite_a_list_cuddled_lists.text new file mode 100644 index 00000000..11793ccd --- /dev/null +++ b/test/tm-cases/not_quite_a_list_cuddled_lists.text @@ -0,0 +1,21 @@ +So: +- This +- is +- a list. + +And: +* *This* is +* a list +* too. + +However, because ASCII art can have long dash/asterisk lines let ensure that: + +- - - - - - - This isn't a list. + +* * Nor is this a list. +- - - Or this. + + +- - - - - - - - - - + + hi there ascii art +- - - - - - - - - - + diff --git a/test/tm-cases/ordered_list_lazy_numbering.html b/test/tm-cases/ordered_list_lazy_numbering.html new file mode 100644 index 00000000..b14dcce5 --- /dev/null +++ b/test/tm-cases/ordered_list_lazy_numbering.html @@ -0,0 +1,25 @@ +

Example 1:

+ +
    +
  1. Most ordered lists
  2. +
  3. Start at number one
  4. +
  5. And go up from there
  6. +
+ +

Example 2:

+ +
    +
  1. Some lists might start from 2
  2. +
  3. And continue from there
  4. +
+ +

Example 3:

+ +
    +
  1. What about 999
  2. +
  3. And going to a thousand +
      +
    1. With some nested offset ordered lists
    2. +
    3. Just for good measure
    4. +
  4. +
diff --git a/test/tm-cases/ordered_list_lazy_numbering.text b/test/tm-cases/ordered_list_lazy_numbering.text new file mode 100644 index 00000000..a53317b6 --- /dev/null +++ b/test/tm-cases/ordered_list_lazy_numbering.text @@ -0,0 +1,17 @@ +Example 1: + +1. Most ordered lists +2. Start at number one +3. And go up from there + +Example 2: + +2. Some lists might start from 2 +3. And continue from there + +Example 3: + +999. What about 999 +1000. And going to a thousand + 7. With some nested offset ordered lists + 8. Just for good measure \ No newline at end of file diff --git a/test/tm-cases/ordered_list_lazy_numbering_issue471.html b/test/tm-cases/ordered_list_lazy_numbering_issue471.html new file mode 100644 index 00000000..0bad6825 --- /dev/null +++ b/test/tm-cases/ordered_list_lazy_numbering_issue471.html @@ -0,0 +1,69 @@ +

This command performs an entire mail transaction.

+ +

The arguments are: + - fromaddr : The address sending this mail. + - toaddrs : A list of addresses to send this mail to. A bare + string will be treated as a list with 1 address. + - msg : The message to send. + - mailoptions : List of ESMTP options (such as 8bitmime) for the + mail command. + - rcptoptions : List of ESMTP options (such as DSN commands) for + all the rcpt commands.

+ +

msg may be a string containing characters in the ASCII range, or a byte +string. A string is encoded to bytes using the ascii codec, and lone +\r and \n characters are converted to \r\n characters.

+ +

If there has been no previous EHLO or HELO command this session, this +method tries ESMTP EHLO first. If the server does ESMTP, message size +and each of the specified options will be passed to it. If EHLO +fails, HELO will be tried and ESMTP options suppressed.

+ +

This method will return normally if the mail is accepted for at least +one recipient. It returns a dictionary, with one entry for each +recipient that was refused. Each entry contains a tuple of the SMTP +error code and the accompanying error message sent by the server.

+ +

This method may raise the following exceptions:

+ +

SMTPHeloError The server didn't reply properly to + the helo greeting. + SMTPRecipientsRefused The server rejected ALL recipients + (no mail was sent). + SMTPSenderRefused The server didn't accept the fromaddr. + SMTPDataError The server replied with an unexpected + error code (other than a refusal of + a recipient). + SMTPNotSupportedError The mailoptions parameter includes 'SMTPUTF8' + but the SMTPUTF8 extension is not supported by + the server.

+ +

Note: the connection will be open even after an exception is raised.

+ +

Example:

+ +
+
+
+

import smtplib + s=smtplib.SMTP("localhost") + tolist=["one@one.org","two@two.org","three@three.org","four@four.org"] + msg = '''\ + ... From: Me@my.org + ... Subject: testin'... + ... + ... This is a test ''' + s.sendmail("me@my.org",tolist,msg) + { "three@three.org" : ( 550 ,"User unknown" ) } + s.quit()

+
+
+
+ +

In the above example, the message was accepted for delivery to three +of the four addresses, and one was rejected, with the error code

+ +
    +
  1. If all addresses are accepted, then the method will return an +empty dictionary.
  2. +
diff --git a/test/tm-cases/ordered_list_lazy_numbering_issue471.opts b/test/tm-cases/ordered_list_lazy_numbering_issue471.opts new file mode 100644 index 00000000..697d1301 --- /dev/null +++ b/test/tm-cases/ordered_list_lazy_numbering_issue471.opts @@ -0,0 +1 @@ +{"extras": ["cuddled-lists"]} \ No newline at end of file diff --git a/test/tm-cases/ordered_list_lazy_numbering_issue471.text b/test/tm-cases/ordered_list_lazy_numbering_issue471.text new file mode 100644 index 00000000..ff35c6b5 --- /dev/null +++ b/test/tm-cases/ordered_list_lazy_numbering_issue471.text @@ -0,0 +1,60 @@ +This command performs an entire mail transaction. + +The arguments are: + - from_addr : The address sending this mail. + - to_addrs : A list of addresses to send this mail to. A bare + string will be treated as a list with 1 address. + - msg : The message to send. + - mail_options : List of ESMTP options (such as 8bitmime) for the + mail command. + - rcpt_options : List of ESMTP options (such as DSN commands) for + all the rcpt commands. + +msg may be a string containing characters in the ASCII range, or a byte +string. A string is encoded to bytes using the ascii codec, and lone +\r and \n characters are converted to \r\n characters. + +If there has been no previous EHLO or HELO command this session, this +method tries ESMTP EHLO first. If the server does ESMTP, message size +and each of the specified options will be passed to it. If EHLO +fails, HELO will be tried and ESMTP options suppressed. + +This method will return normally if the mail is accepted for at least +one recipient. It returns a dictionary, with one entry for each +recipient that was refused. Each entry contains a tuple of the SMTP +error code and the accompanying error message sent by the server. + +This method may raise the following exceptions: + + SMTPHeloError The server didn't reply properly to + the helo greeting. + SMTPRecipientsRefused The server rejected ALL recipients + (no mail was sent). + SMTPSenderRefused The server didn't accept the from_addr. + SMTPDataError The server replied with an unexpected + error code (other than a refusal of + a recipient). + SMTPNotSupportedError The mail_options parameter includes 'SMTPUTF8' + but the SMTPUTF8 extension is not supported by + the server. + +Note: the connection will be open even after an exception is raised. + +Example: + + >>> import smtplib + >>> s=smtplib.SMTP("localhost") + >>> tolist=["one@one.org","two@two.org","three@three.org","four@four.org"] + >>> msg = '''\ + ... From: Me@my.org + ... Subject: testin'... + ... + ... This is a test ''' + >>> s.sendmail("me@my.org",tolist,msg) + { "three@three.org" : ( 550 ,"User unknown" ) } + >>> s.quit() + +In the above example, the message was accepted for delivery to three +of the four addresses, and one was rejected, with the error code +550. If all addresses are accepted, then the method will return an +empty dictionary. diff --git a/test/tm-cases/pyshell_and_fenced_code_blocks.html b/test/tm-cases/pyshell_and_fenced_code_blocks.html new file mode 100644 index 00000000..28b13705 --- /dev/null +++ b/test/tm-cases/pyshell_and_fenced_code_blocks.html @@ -0,0 +1,37 @@ +

From Recipe 302035

+ +

Some examples:

+ +
+
>>> nprint(9876543210)
+'9 876 543 210'
+>>> nprint(987654321, period=1, delimiter=",")
+'9,8,7,6,5,4,3,2,1,0'
+
+
+ +

Indented a bit:

+ +
+
>>> 1 + 1
+2
+
+
+ +

Part of blockquote:

+ +
+
+
>>> 1 + 1
+2
+
+
+
+ +

Cuddled to previous para (and at end of document):

+ +
+
>>> 2 + 2
+4
+
+
diff --git a/test/tm-cases/pyshell_and_fenced_code_blocks.opts b/test/tm-cases/pyshell_and_fenced_code_blocks.opts new file mode 100644 index 00000000..ff194214 --- /dev/null +++ b/test/tm-cases/pyshell_and_fenced_code_blocks.opts @@ -0,0 +1 @@ +{"extras": ["pyshell", "fenced-code-blocks"]} diff --git a/test/tm-cases/pyshell_and_fenced_code_blocks.tags b/test/tm-cases/pyshell_and_fenced_code_blocks.tags new file mode 100644 index 00000000..a6296bc7 --- /dev/null +++ b/test/tm-cases/pyshell_and_fenced_code_blocks.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments pyshell diff --git a/test/tm-cases/pyshell_and_fenced_code_blocks.text b/test/tm-cases/pyshell_and_fenced_code_blocks.text new file mode 100644 index 00000000..f718ec9e --- /dev/null +++ b/test/tm-cases/pyshell_and_fenced_code_blocks.text @@ -0,0 +1,22 @@ +# From Recipe 302035 + +Some examples: + +>>> nprint(9876543210) +'9 876 543 210' +>>> nprint(987654321, period=1, delimiter=",") +'9,8,7,6,5,4,3,2,1,0' + +Indented a bit: + + >>> 1 + 1 + 2 + +Part of blockquote: + +> >>> 1 + 1 +> 2 + +Cuddled to previous para (and at end of document): +>>> 2 + 2 +4 diff --git a/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.html b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.html new file mode 100644 index 00000000..58d5d439 --- /dev/null +++ b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.html @@ -0,0 +1,15 @@ +

Example:

+ +
+
+
if True:
+    print()
+
+    print()
+
+    print()
+
+    print()
+
+
+
diff --git a/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.opts b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.opts new file mode 100644 index 00000000..91560387 --- /dev/null +++ b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.opts @@ -0,0 +1 @@ +{"extras": ["fenced-code-blocks"]} \ No newline at end of file diff --git a/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.tags b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.tags new file mode 100644 index 00000000..12bca88c --- /dev/null +++ b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.tags @@ -0,0 +1 @@ +extra fenced-code-blocks pygments \ No newline at end of file diff --git a/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.text b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.text new file mode 100644 index 00000000..a77adaca --- /dev/null +++ b/test/tm-cases/quoted_fenced_code_blocks_whitespace_around_indented_lines.text @@ -0,0 +1,12 @@ +### Example: + +> ```python +> if True: +> print() +> +> print() +> +> print() +> +> print() +> ``` \ No newline at end of file diff --git a/test/tm-cases/relative_links_safe_mode.html b/test/tm-cases/relative_links_safe_mode.html new file mode 100644 index 00000000..e94bea79 --- /dev/null +++ b/test/tm-cases/relative_links_safe_mode.html @@ -0,0 +1,6 @@ +

link1 +link2 +link3 +link4 +link5 +link6

diff --git a/test/tm-cases/relative_links_safe_mode.opts b/test/tm-cases/relative_links_safe_mode.opts new file mode 100644 index 00000000..ad487c04 --- /dev/null +++ b/test/tm-cases/relative_links_safe_mode.opts @@ -0,0 +1 @@ +{"safe_mode": "escape"} diff --git a/test/tm-cases/relative_links_safe_mode.text b/test/tm-cases/relative_links_safe_mode.text new file mode 100644 index 00000000..d445cfd1 --- /dev/null +++ b/test/tm-cases/relative_links_safe_mode.text @@ -0,0 +1,6 @@ +[link1](https://www.hostname.com/absolute/path) +[link2](https://www.hostname.com/absolute/path#anchor-on-another-page) +[link3](#anchor-on-this-page) +[link4](/) +[link5](/absolute/path) +[link6](../relative/path) diff --git a/test/tm-cases/safe_mode_issue621.html b/test/tm-cases/safe_mode_issue621.html new file mode 100644 index 00000000..2bd9356b --- /dev/null +++ b/test/tm-cases/safe_mode_issue621.html @@ -0,0 +1 @@ +

Chromium

diff --git a/test/tm-cases/safe_mode_issue621.opts b/test/tm-cases/safe_mode_issue621.opts new file mode 100644 index 00000000..de64198e --- /dev/null +++ b/test/tm-cases/safe_mode_issue621.opts @@ -0,0 +1 @@ +{'safe_mode': 'escape'} \ No newline at end of file diff --git a/test/tm-cases/safe_mode_issue621.text b/test/tm-cases/safe_mode_issue621.text new file mode 100644 index 00000000..f8c742d4 --- /dev/null +++ b/test/tm-cases/safe_mode_issue621.text @@ -0,0 +1 @@ +[Chromium](https://chromium.googlesource.com/v8/v8.git/+/refs/heads/beta) \ No newline at end of file diff --git a/test/tm-cases/script-and-style-blocks.html b/test/tm-cases/script-and-style-blocks.html new file mode 100644 index 00000000..a855b8ba --- /dev/null +++ b/test/tm-cases/script-and-style-blocks.html @@ -0,0 +1,13 @@ + + + + +

Some other text

diff --git a/test/tm-cases/script-and-style-blocks.text b/test/tm-cases/script-and-style-blocks.text new file mode 100644 index 00000000..73c508e7 --- /dev/null +++ b/test/tm-cases/script-and-style-blocks.text @@ -0,0 +1,13 @@ + + + + +Some other text diff --git a/test/tm-cases/seperated_list_items.html b/test/tm-cases/seperated_list_items.html new file mode 100644 index 00000000..140ad893 --- /dev/null +++ b/test/tm-cases/seperated_list_items.html @@ -0,0 +1,12 @@ +
    +
  • Item 1 +ABCDEF

  • +
  • Item 2

    + +
      +
    • Item 3 +
        +
      • Item 4
      • +
    • +
  • +
diff --git a/test/tm-cases/seperated_list_items.text b/test/tm-cases/seperated_list_items.text new file mode 100644 index 00000000..1a5c991a --- /dev/null +++ b/test/tm-cases/seperated_list_items.text @@ -0,0 +1,6 @@ +- Item 1 + ABCDEF + +- Item 2 + - Item 3 + - Item 4 diff --git a/test/tm-cases/smarty_pants.html b/test/tm-cases/smarty_pants.html index 200c8977..b44af4da 100644 --- a/test/tm-cases/smarty_pants.html +++ b/test/tm-cases/smarty_pants.html @@ -37,9 +37,9 @@

Edge case: contractions

For common contractions, a space single-prime non-space combination should produce an apostrophe (&#8217;) instead of an opening scare quote (&#8216;).

-

Here is the full list: ’tis, ’twas, ’twer, ’neath, ’o, ’n, ’round, ’bout, ’twixt, ’nuff, ’fraid, ’sup
-The full list, capitalized: ’Tis, ’Twas, ’Twer, ’Neath, ’O, ’N, ’Round, ’Bout, ’Twixt, ’Nuff, ’Fraid, ’Sup
-And normal text: ‘random ‘stuff ‘that ‘shouldn’t ‘be ‘detected ‘as ‘contractions
+

Here is the full list: ’tis, ’twas, ’twer, ’neath, ’o, ’n, ’round, ’bout, ’twixt, ’nuff, ’fraid, ’sup
+The full list, capitalized: ’Tis, ’Twas, ’Twer, ’Neath, ’O, ’N, ’Round, ’Bout, ’Twixt, ’Nuff, ’Fraid, ’Sup
+And normal text: ‘random ‘stuff ‘that ‘shouldn’t ‘be ‘detected ‘as ‘contractions
And years: ’29 ’91 ‘1942 ‘2001 ‘2010

Like quotation marks, the year shorthand expects a year, e.g. '29, to be followed by whitespace or sentence-ending punctuation. Numbers like '456.7 will throw it off, but those aren’t entered very often.

diff --git a/test/tm-cases/smarty_pants_issue611.html b/test/tm-cases/smarty_pants_issue611.html new file mode 100644 index 00000000..b926e73d --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.html @@ -0,0 +1,3 @@ +

ho ho — ho ho

+ +

ho “ho” — ho ho

diff --git a/test/tm-cases/smarty_pants_issue611.opts b/test/tm-cases/smarty_pants_issue611.opts new file mode 100644 index 00000000..d0390c68 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.opts @@ -0,0 +1 @@ +{"extras": ["smarty-pants"]} diff --git a/test/tm-cases/smarty_pants_issue611.text b/test/tm-cases/smarty_pants_issue611.text new file mode 100644 index 00000000..d0ec3d27 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue611.text @@ -0,0 +1,3 @@ +ho ho --- ho ho + +ho "ho" --- ho ho \ No newline at end of file diff --git a/test/tm-cases/smarty_pants_issue620.html b/test/tm-cases/smarty_pants_issue620.html new file mode 100644 index 00000000..c409b145 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue620.html @@ -0,0 +1,15 @@ +

Some HTML5 block level elements that should be hashed so that smarty-pants doesn’t interfere

+ +
+ jim@example.com
+ +1 (415) 555‑0132 +
+ + + An alternative text describing what your canvas displays. + + + diff --git a/test/tm-cases/smarty_pants_issue620.opts b/test/tm-cases/smarty_pants_issue620.opts new file mode 100644 index 00000000..d0390c68 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue620.opts @@ -0,0 +1 @@ +{"extras": ["smarty-pants"]} diff --git a/test/tm-cases/smarty_pants_issue620.text b/test/tm-cases/smarty_pants_issue620.text new file mode 100644 index 00000000..60c851d2 --- /dev/null +++ b/test/tm-cases/smarty_pants_issue620.text @@ -0,0 +1,15 @@ +Some HTML5 block level elements that should be hashed so that smarty-pants doesn't interfere + +
+ jim@example.com
+ +1 (415) 555‑0132 +
+ + + An alternative text describing what your canvas displays. + + + \ No newline at end of file diff --git a/test/tm-cases/spoiler.html b/test/tm-cases/spoiler.html index 71e1c8ae..b0d5a3fb 100644 --- a/test/tm-cases/spoiler.html +++ b/test/tm-cases/spoiler.html @@ -7,22 +7,22 @@

[Second]

-

! But this is
+

! But this is
not a spoiler

[Third]

-

A multi-line spoiler
+

A multi-line spoiler
has ! multiple times

[Fourth]

-

Alignment
- has no effect
+

Alignment
+ has no effect
on spoilers

diff --git a/test/tm-cases/strike.html b/test/tm-cases/strike.html index 1821a899..ce6c4368 100644 --- a/test/tm-cases/strike.html +++ b/test/tm-cases/strike.html @@ -1,3 +1,3 @@ -

This is strike line.

+

This is strike line.

-

So is this word.

+

So is this word.

diff --git a/test/tm-cases/sublist-para.html b/test/tm-cases/sublist-para.html index a2f551b1..484e67e4 100644 --- a/test/tm-cases/sublist-para.html +++ b/test/tm-cases/sublist-para.html @@ -11,7 +11,7 @@
  • Add Komodo chrome (XUL, JavaScript, CSS, DTDs).
  • -

    What this means is that work on and add significant functionality...

    +

    What this means is that work on and add significant functionality...

  • Komodo uses the same extension mechanisms as Firefox...

  • Komodo builds and runs on Windows, Linux and ...

  • -

    + diff --git a/test/tm-cases/syntax_color.html b/test/tm-cases/syntax_color.html deleted file mode 100644 index ae9ea34d..00000000 --- a/test/tm-cases/syntax_color.html +++ /dev/null @@ -1,15 +0,0 @@ -

    Here is some sample code:

    - -
    import sys
    -def main(argv=sys.argv):
    -    logging.basicConfig()
    -    log.info('hi')
    -
    - -

    and:

    - -
    use 'zlib'
    -sub main(argv)
    -    puts 'hi'
    -end
    -
    diff --git a/test/tm-cases/syntax_color.opts b/test/tm-cases/syntax_color.opts deleted file mode 100644 index 95dfd418..00000000 --- a/test/tm-cases/syntax_color.opts +++ /dev/null @@ -1 +0,0 @@ -{"extras": ["code-color"]} diff --git a/test/tm-cases/syntax_color.tags b/test/tm-cases/syntax_color.tags deleted file mode 100644 index b9a5e485..00000000 --- a/test/tm-cases/syntax_color.tags +++ /dev/null @@ -1 +0,0 @@ -extra code-color pygments diff --git a/test/tm-cases/syntax_color.text b/test/tm-cases/syntax_color.text deleted file mode 100644 index b4b30e55..00000000 --- a/test/tm-cases/syntax_color.text +++ /dev/null @@ -1,15 +0,0 @@ -Here is some sample code: - - :::python - import sys - def main(argv=sys.argv): - logging.basicConfig() - log.info('hi') - -and: - - :::ruby - use 'zlib' - sub main(argv) - puts 'hi' - end diff --git a/test/tm-cases/syntax_color_opts.html b/test/tm-cases/syntax_color_opts.html deleted file mode 100644 index 5c928c2d..00000000 --- a/test/tm-cases/syntax_color_opts.html +++ /dev/null @@ -1,15 +0,0 @@ -

    Here is some sample code:

    - -
    import sys
    -def main(argv=sys.argv):
    -    logging.basicConfig()
    -    log.info('hi')
    -
    - -

    and:

    - -
    use 'zlib'
    -sub main(argv)
    -    puts 'hi'
    -end
    -
    diff --git a/test/tm-cases/syntax_color_opts.opts b/test/tm-cases/syntax_color_opts.opts deleted file mode 100644 index 3c400432..00000000 --- a/test/tm-cases/syntax_color_opts.opts +++ /dev/null @@ -1 +0,0 @@ -{"extras": {"code-color": {"noclasses": True}}} diff --git a/test/tm-cases/syntax_color_opts.tags b/test/tm-cases/syntax_color_opts.tags deleted file mode 100644 index b9a5e485..00000000 --- a/test/tm-cases/syntax_color_opts.tags +++ /dev/null @@ -1 +0,0 @@ -extra code-color pygments diff --git a/test/tm-cases/syntax_color_opts.text b/test/tm-cases/syntax_color_opts.text deleted file mode 100644 index b4b30e55..00000000 --- a/test/tm-cases/syntax_color_opts.text +++ /dev/null @@ -1,15 +0,0 @@ -Here is some sample code: - - :::python - import sys - def main(argv=sys.argv): - logging.basicConfig() - log.info('hi') - -and: - - :::ruby - use 'zlib' - sub main(argv) - puts 'hi' - end diff --git a/test/tm-cases/tables.html b/test/tm-cases/tables.html index 0d9abca4..3f919a1e 100644 --- a/test/tm-cases/tables.html +++ b/test/tm-cases/tables.html @@ -130,13 +130,28 @@

    table with cuddled following content

    Note: This passes GFM, but fails in PHP-Markdown.

    -

    FAIL: table with cuddled leading content

    +

    table with cuddled leading content

    -

    before -| Header 1 | Header 2 | -| -------- | -------- | -| Cell 1 | Cell 2 | -| Cell 3 | Cell 4 |

    +

    This would have failed in <=2.4.13

    + + + + + + + + + + + + + + + + + + +
    Header 1Header 2
    Cell 1Cell 2
    Cell 3Cell 4

    single column single leading bar

    @@ -379,3 +394,14 @@

    escaping of pipes

    + +

    table without rows

    + + + + + + + + +
    abcdef
    diff --git a/test/tm-cases/tables.text b/test/tm-cases/tables.text index 0b167420..ed7512ae 100644 --- a/test/tm-cases/tables.text +++ b/test/tm-cases/tables.text @@ -50,9 +50,9 @@ after *Note:* This passes GFM, but fails in PHP-Markdown. -# FAIL: table with cuddled leading content +# table with cuddled leading content -before +This would have failed in <=2.4.13 | Header 1 | Header 2 | | -------- | -------- | | Cell 1 | Cell 2 | @@ -156,3 +156,8 @@ the rule is it must have at least a single dash in there. | A | \| | C \| C | |--- |--- | ------ | |\|\|| BB | C | + +# table without rows + +| abc | def | +| --- | --- | diff --git a/test/tm-cases/tables_nbsp_issue629.html b/test/tm-cases/tables_nbsp_issue629.html new file mode 100644 index 00000000..eb1c0b95 --- /dev/null +++ b/test/tm-cases/tables_nbsp_issue629.html @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
    AB
    Foo123
    diff --git a/test/tm-cases/tables_nbsp_issue629.opts b/test/tm-cases/tables_nbsp_issue629.opts new file mode 100644 index 00000000..0fe946d7 --- /dev/null +++ b/test/tm-cases/tables_nbsp_issue629.opts @@ -0,0 +1 @@ +{'extras': ['tables']} \ No newline at end of file diff --git a/test/tm-cases/tables_nbsp_issue629.text b/test/tm-cases/tables_nbsp_issue629.text new file mode 100644 index 00000000..56aaad75 --- /dev/null +++ b/test/tm-cases/tables_nbsp_issue629.text @@ -0,0 +1,3 @@ +| A | B | +|-----|-----|  +| Foo | 123 | \ No newline at end of file diff --git a/test/tm-cases/tg-spoiler.html b/test/tm-cases/tg-spoiler.html new file mode 100644 index 00000000..6d903764 --- /dev/null +++ b/test/tm-cases/tg-spoiler.html @@ -0,0 +1,5 @@ +

    This is some Telegram spoiler text.

    + +

    This is some Telegram spoiler with more words text.

    + +

    This spoiler got more spoilers

    diff --git a/test/tm-cases/tg-spoiler.opts b/test/tm-cases/tg-spoiler.opts new file mode 100644 index 00000000..e3da2c96 --- /dev/null +++ b/test/tm-cases/tg-spoiler.opts @@ -0,0 +1 @@ +{"extras": ["tg-spoiler"]} \ No newline at end of file diff --git a/test/tm-cases/tg-spoiler.tags b/test/tm-cases/tg-spoiler.tags new file mode 100644 index 00000000..46fef954 --- /dev/null +++ b/test/tm-cases/tg-spoiler.tags @@ -0,0 +1 @@ +extras tg-spoiler \ No newline at end of file diff --git a/test/tm-cases/tg-spoiler.text b/test/tm-cases/tg-spoiler.text new file mode 100644 index 00000000..d79cc57c --- /dev/null +++ b/test/tm-cases/tg-spoiler.text @@ -0,0 +1,5 @@ +This is some ||Telegram spoiler|| text. + +This is some || Telegram spoiler with more words || text. + +This ||spoiler || got more || spoilers|| \ No newline at end of file diff --git a/test/tm-cases/toc_4.html b/test/tm-cases/toc_4.html index f7900888..238c4ebe 100644 --- a/test/tm-cases/toc_4.html +++ b/test/tm-cases/toc_4.html @@ -1,6 +1,6 @@

    Python

    -

    蟒蛇

    +

    蟒蛇

    • 外形特性
    • @@ -9,7 +9,7 @@

      蟒蛇

      Markdown

      -

      标记语言

      +

      标记语言

      • 类型
      • diff --git a/test/tm-cases/toc_4.toc_html b/test/tm-cases/toc_4.toc_html index a5543cd0..cd273f42 100644 --- a/test/tm-cases/toc_4.toc_html +++ b/test/tm-cases/toc_4.toc_html @@ -1,8 +1,8 @@ diff --git a/test/tm-cases/toc_duplicate_entries.html b/test/tm-cases/toc_duplicate_entries.html new file mode 100644 index 00000000..dc051bf7 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.html @@ -0,0 +1,5 @@ +

        abc

        + +

        abc

        + +

        abc

        diff --git a/test/tm-cases/toc_duplicate_entries.opts b/test/tm-cases/toc_duplicate_entries.opts new file mode 100644 index 00000000..53a34fa2 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.opts @@ -0,0 +1,6 @@ +{ + "extras": { + "toc": {"depth": 3}, + "header-ids": {"mixed": True} + } +} diff --git a/test/tm-cases/toc_duplicate_entries.text b/test/tm-cases/toc_duplicate_entries.text new file mode 100644 index 00000000..c4f0e0a4 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.text @@ -0,0 +1,3 @@ +# abc +# abc +# abc diff --git a/test/tm-cases/toc_duplicate_entries.toc_html b/test/tm-cases/toc_duplicate_entries.toc_html new file mode 100644 index 00000000..72262013 --- /dev/null +++ b/test/tm-cases/toc_duplicate_entries.toc_html @@ -0,0 +1,5 @@ + diff --git a/test/tm-cases/toc_prepend.html b/test/tm-cases/toc_prepend.html new file mode 100644 index 00000000..7aa0a0e5 --- /dev/null +++ b/test/tm-cases/toc_prepend.html @@ -0,0 +1,40 @@ + + +

        README for Blah

        + +

        Introduction

        + +

        The Meat

        + +

        Beef

        + +
        Steak
        + +
        Burgers
        + +

        Chicken

        + +

        Pork

        + +

        Mmmmmmmm, bacon

        + +

        At the top level again!?

        diff --git a/test/tm-cases/toc_prepend.opts b/test/tm-cases/toc_prepend.opts new file mode 100644 index 00000000..261151cd --- /dev/null +++ b/test/tm-cases/toc_prepend.opts @@ -0,0 +1 @@ +{"extras": {"toc": {"prepend": True}}} diff --git a/test/tm-cases/toc_prepend.tags b/test/tm-cases/toc_prepend.tags new file mode 100644 index 00000000..2b2472e0 --- /dev/null +++ b/test/tm-cases/toc_prepend.tags @@ -0,0 +1 @@ +toc extra diff --git a/test/tm-cases/toc_prepend.text b/test/tm-cases/toc_prepend.text new file mode 100644 index 00000000..34f629a6 --- /dev/null +++ b/test/tm-cases/toc_prepend.text @@ -0,0 +1,20 @@ +# README for Blah + +## Introduction + +## The Meat + +### Beef + +##### Steak + +##### Burgers + +### Chicken + +### Pork + +#### Mmmmmmmm, bacon + +# At the *top* level again!? + diff --git a/test/tm-cases/toc_prepend.toc_html b/test/tm-cases/toc_prepend.toc_html new file mode 100644 index 00000000..08288703 --- /dev/null +++ b/test/tm-cases/toc_prepend.toc_html @@ -0,0 +1,20 @@ + diff --git a/test/tm-cases/trailing_table_whitespace.html b/test/tm-cases/trailing_table_whitespace.html new file mode 100644 index 00000000..e0a19866 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.html @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + +
        ProsCons
        Unique and refreshing take on the genreMay not resonate with all viewers
        Cult classic statusOver-the-top humor may polarize audiences
        Influential in launching careersNiche appeal among comedy aficionados
        diff --git a/test/tm-cases/trailing_table_whitespace.opts b/test/tm-cases/trailing_table_whitespace.opts new file mode 100644 index 00000000..23983798 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.opts @@ -0,0 +1 @@ +{"extras": ["tables"]} diff --git a/test/tm-cases/trailing_table_whitespace.text b/test/tm-cases/trailing_table_whitespace.text new file mode 100644 index 00000000..08748799 --- /dev/null +++ b/test/tm-cases/trailing_table_whitespace.text @@ -0,0 +1,5 @@ +| Pros | Cons | +|-----------------------------------------|------------------------------------------------| +| Unique and refreshing take on the genre | May not resonate with all viewers | +| Cult classic status | Over-the-top humor may polarize audiences | +| Influential in launching careers | Niche appeal among comedy aficionados | diff --git a/test/tm-cases/underline.html b/test/tm-cases/underline.html new file mode 100644 index 00000000..ff8f7a47 --- /dev/null +++ b/test/tm-cases/underline.html @@ -0,0 +1 @@ +

        This is some underline text.

        diff --git a/test/tm-cases/underline.opts b/test/tm-cases/underline.opts new file mode 100644 index 00000000..5722f05c --- /dev/null +++ b/test/tm-cases/underline.opts @@ -0,0 +1 @@ +{"extras": ["underline"]} diff --git a/test/tm-cases/underline.tags b/test/tm-cases/underline.tags new file mode 100644 index 00000000..c166945c --- /dev/null +++ b/test/tm-cases/underline.tags @@ -0,0 +1 @@ +extras underline diff --git a/test/tm-cases/underline.text b/test/tm-cases/underline.text new file mode 100644 index 00000000..8ee0c9f5 --- /dev/null +++ b/test/tm-cases/underline.text @@ -0,0 +1 @@ +This is some --underline-- text. diff --git a/test/tm-cases/underline_html_comment.html b/test/tm-cases/underline_html_comment.html new file mode 100644 index 00000000..e780f603 --- /dev/null +++ b/test/tm-cases/underline_html_comment.html @@ -0,0 +1,13 @@ +

        + +

        + +

        + +

        This is an !underlined link¡: https://github.com. + +

        + +

        + +

        This is a sentence. [definitely]

        diff --git a/test/tm-cases/underline_html_comment.opts b/test/tm-cases/underline_html_comment.opts new file mode 100644 index 00000000..5722f05c --- /dev/null +++ b/test/tm-cases/underline_html_comment.opts @@ -0,0 +1 @@ +{"extras": ["underline"]} diff --git a/test/tm-cases/underline_html_comment.tags b/test/tm-cases/underline_html_comment.tags new file mode 100644 index 00000000..c166945c --- /dev/null +++ b/test/tm-cases/underline_html_comment.tags @@ -0,0 +1 @@ +extras underline diff --git a/test/tm-cases/underline_html_comment.text b/test/tm-cases/underline_html_comment.text new file mode 100644 index 00000000..0a8c7de0 --- /dev/null +++ b/test/tm-cases/underline_html_comment.text @@ -0,0 +1,13 @@ + + + + + + +This is an !--underlined link--¡: ----. + + + + + +This is a sentence. [--definitely--] diff --git a/test/tm-cases/wavedrom.html b/test/tm-cases/wavedrom.html new file mode 100644 index 00000000..ddedb0d1 --- /dev/null +++ b/test/tm-cases/wavedrom.html @@ -0,0 +1,348 @@ +

        Here is a basic wavedrom diagram:

        + +
        Alfa +
        + +

        And here is a more complex one, inside of a list

        + +
          +
        • More complex diagram +
            +
          • Inside of nested list +
            pclkPclknclkNclkclk0clk1clk2clk3clk4 +
          • +
          • Making sure not to break indentation
          • +
        • +
        diff --git a/test/tm-cases/wavedrom.opts b/test/tm-cases/wavedrom.opts new file mode 100644 index 00000000..7085fe10 --- /dev/null +++ b/test/tm-cases/wavedrom.opts @@ -0,0 +1 @@ +{"extras": ["wavedrom"]} \ No newline at end of file diff --git a/test/tm-cases/wavedrom.tags b/test/tm-cases/wavedrom.tags new file mode 100644 index 00000000..270c2eef --- /dev/null +++ b/test/tm-cases/wavedrom.tags @@ -0,0 +1 @@ +extra wavedrom \ No newline at end of file diff --git a/test/tm-cases/wavedrom.text b/test/tm-cases/wavedrom.text new file mode 100644 index 00000000..f097e0cd --- /dev/null +++ b/test/tm-cases/wavedrom.text @@ -0,0 +1,24 @@ +Here is a basic wavedrom diagram: +```wavedrom +{ "signal": [{ "name": "Alfa", "wave": "01.zx=ud.23.456789" }] } +``` + +And here is a more complex one, inside of a list + +* More complex diagram + * Inside of nested list + ```wavedrom + { signal: [ + { name: "pclk", wave: 'p.......' }, + { name: "Pclk", wave: 'P.......' }, + { name: "nclk", wave: 'n.......' }, + { name: "Nclk", wave: 'N.......' }, + {}, + { name: 'clk0', wave: 'phnlPHNL' }, + { name: 'clk1', wave: 'xhlhLHl.' }, + { name: 'clk2', wave: 'hpHplnLn' }, + { name: 'clk3', wave: 'nhNhplPl' }, + { name: 'clk4', wave: 'xlh.L.Hx' }, + ]} + ``` + * Making sure not to break indentation \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.html b/test/tm-cases/wavedrom_no_embed.html new file mode 100755 index 00000000..6f343626 --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.html @@ -0,0 +1,29 @@ +

        Here is a basic wavedrom diagram:

        + + + +

        And here is a more complex one, inside of a list

        + +
          +
        • More complex diagram +
            +
          • Inside of nested list +
          • +
          • Making sure not to break indentation
          • +
        • +
        diff --git a/test/tm-cases/wavedrom_no_embed.opts b/test/tm-cases/wavedrom_no_embed.opts new file mode 100644 index 00000000..ac599d07 --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.opts @@ -0,0 +1 @@ +{"extras": {"wavedrom": {"prefer_embed_svg": False}}} \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.tags b/test/tm-cases/wavedrom_no_embed.tags new file mode 100644 index 00000000..270c2eef --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.tags @@ -0,0 +1 @@ +extra wavedrom \ No newline at end of file diff --git a/test/tm-cases/wavedrom_no_embed.text b/test/tm-cases/wavedrom_no_embed.text new file mode 100644 index 00000000..f378758f --- /dev/null +++ b/test/tm-cases/wavedrom_no_embed.text @@ -0,0 +1,24 @@ +Here is a basic wavedrom diagram: +```wavedrom +{ "signal": [{ "name": "Alfa", "wave": "01.zx=ud.23.456789" }] } +``` + +And here is a more complex one, inside of a list + +* More complex diagram + * Inside of nested list + ```wavedrom + { signal: [ + { name: "pclk", wave: 'p.......' }, + { name: "Pclk", wave: 'P.......' }, + { name: "nclk", wave: 'n.......' }, + { name: "Nclk", wave: 'N.......' }, + {}, + { name: 'clk0', wave: 'phnlPHNL' }, + { name: 'clk1', wave: 'xhlhLHl.' }, + { name: 'clk2', wave: 'hpHplnLn' }, + { name: 'clk3', wave: 'nhNhplPl' }, + { name: 'clk4', wave: 'xlh.L.Hx' }, + ]} + ``` + * Making sure not to break indentation diff --git a/test/tm-cases/wiki_tables.html b/test/tm-cases/wiki_tables.html index 45d7cc35..64bc1b52 100644 --- a/test/tm-cases/wiki_tables.html +++ b/test/tm-cases/wiki_tables.html @@ -1,28 +1,123 @@ - - - - - - + + + + + + + + + + + + + + + + + + + + + + +
        YearTemperature (low)Temperature (high)
        1900-1025
        1910-1530
        1920-1032
        YearTemperature (low)Temperature (high)
        1900-1025
        1910-1530
        1920-1032
        + +

        With header row

        + + + + + + + + + + + + + + + + + + + + + + + + +
        NameClassRaceLevel
        VladBarbarianDragonborn12
        JimboRogueHalfling13
        + +

        With only header row

        + + + + + + + + + + +
        NameClassRaceLevel
        + +

        With header row, alternate spacing

        + + + + + + + + + + + + + + + + + + + + + + + +
        NameClassRaceLevel
        VladBarbarianDragonborn12
        JimboRogueHalfling13

        just one line

        - - - + + + + + + +
        foobarbaz
        foobarbaz

        blockquote

        - - - - + + + + + + + + + + + +
        grinchstolexmas
        greeneggsham
        grinchstolexmas
        greeneggsham

        -- Dr. Seuss

        @@ -31,7 +126,10 @@

        blockquote

        end of file

        - - - + + + + + +
        ResourceNotFoundIf :login does not exist
        ResourceNotFoundIf :login does not exist
        diff --git a/test/tm-cases/wiki_tables.tags b/test/tm-cases/wiki_tables.tags index b333de63..362500d5 100644 --- a/test/tm-cases/wiki_tables.tags +++ b/test/tm-cases/wiki_tables.tags @@ -1 +1 @@ -extra wiki-tables issue66 +extra wiki-tables diff --git a/test/tm-cases/wiki_tables.text b/test/tm-cases/wiki_tables.text index a707804b..1128d4bf 100644 --- a/test/tm-cases/wiki_tables.text +++ b/test/tm-cases/wiki_tables.text @@ -3,6 +3,21 @@ || 1910 || -15 || 30 || || 1920 || -10 || 32 || +# With header row + +||~ Name ||~ Class ||~ Race ||~ Level || +|| Vlad || Barbarian || Dragonborn || 12 || +|| Jimbo || Rogue || Halfling || 13 || + +# With only header row + +||~ Name ||~ Class ||~ Race ||~ Level || + +# With header row, alternate spacing + +|| ~Name || ~Class || ~Race || ~Level || +|| Vlad || Barbarian || Dragonborn || 12 || +|| Jimbo || Rogue || Halfling || 13 || # just one line diff --git a/test/tm-cases/xss_issue_362.html b/test/tm-cases/xss_issue_362.html new file mode 100644 index 00000000..9d878bd3 --- /dev/null +++ b/test/tm-cases/xss_issue_362.html @@ -0,0 +1,2 @@ +

        <iframe +onload=alert()//

        diff --git a/test/tm-cases/xss_issue_362.opts b/test/tm-cases/xss_issue_362.opts new file mode 100644 index 00000000..8d202ad0 --- /dev/null +++ b/test/tm-cases/xss_issue_362.opts @@ -0,0 +1 @@ +{"safe_mode": True} \ No newline at end of file diff --git a/test/tm-cases/xss_issue_362.text b/test/tm-cases/xss_issue_362.text new file mode 100644 index 00000000..3016199a --- /dev/null +++ b/test/tm-cases/xss_issue_362.text @@ -0,0 +1,2 @@ +