Repository navigation
Conversation
Crozzers
left a comment
There was a problem hiding this comment.
Changelog also needs updating
| including an operator cell such as ```` ``|`` ````. A pipe immediately after the | ||
| closing delimiter separates the next cell. | ||
|
|
||
| The `markdown-file-links` extra converts `.md` file links to `.html`, preserving |
There was a problem hiding this comment.
Not really needed here in the readme. It clogs it up and begs the question "why is this extra so important? Why not add the other 20 extras right here".
This should go in dedicated a wiki page for the extra, if one doesn't already exist
|
|
||
| def test_markdown_file_links_query_and_fragment(self): | ||
| cases = ( | ||
| ("guide.md", "guide.html"), |
There was a problem hiding this comment.
This should go in a testcase file in tests/tm-cases/, same format as the others.
Usually stuff is only put here if it's difficult to express in those test files, or so large it's impractical to commit in a file
There was a problem hiding this comment.
Plus if I make this test fail an assertion on purpose I get this error, rather than anything useful. This is an issue with the test harness rather than your changes specifically, but another reason to put it in tm-cases, which doesn't have that issue
Traceback (most recent call last):
File "/mnt/nas/Python/python-markdown2/test/test.py", line 54, in <module>
retval = testlib.harness(testdir_from_ns=testdir_from_ns,
default_tags=default_tags)
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 703, in harness
result = test(testdir_from_ns, tags, setup_func=setup_func)
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 396, in test
result = runner.run(suite)
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 539, in run
result.printSummary()
~~~~~~~~~~~~~~~~~~~^^
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 506, in printSummary
self.printErrorList('FAIL', self.failures)
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 512, in printErrorList
% (flavour, self.getDescription(test)))
~~~~~~~~~~~~~~~~~~~^^^^^^
File "/mnt/nas/Python/python-markdown2/test/testlib.py", line 472, in getDescription
if test._testlib_explicit_tags_:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_SubTest' object has no attribute '_testlib_explicit_tags_'
| for key, url in self.md.urls.items(): | ||
| if url.endswith('.md'): | ||
| self.md.urls[key] = url.removesuffix('.md') + '.html' | ||
| self.md.urls[key] = self._convert_url(url) |
There was a problem hiding this comment.
If previously self.md.urls was only mutated if the link was deemed valid (endswith('.md')), then shouldn't this do a similar check to L3949?
Saves us potentially polluting the dict with random extra URLs?
With
markdown-file-links,[guide](guide.md#install)keeps pointing to Markdown instead of HTML. Conversely,[part](guide.html#part.md)changes the fragment to#part.html. The same suffix check affects link definitions.Split off query/fragment suffixes before checking the
.mdfilename and share that conversion between inline links and definitions. Preserve the suffix exactly, including empty?/#delimiters. Also let the extra run after definitions are stripped, so a document containing only a reference link is converted without needing another.mdin the body.Add three regression tests covering 34 inline/reference combinations,
link_defs=False, and unchanged inline images. Update the README with the query/fragment behavior.Validation on Windows, CPython 3.13.5:
cd test && python test.py -- -knownfailurepasses all 299 selected tests with all optional dependencies installed (including version-specific Pygments fixture selection).python test/test_redos.py: all 10 cases pass.git diff --check: clean. No PEP8 diagnostics on added Python lines; existing whole-file diagnostics remain (markdown2.py 412 to 410, test_markdown2.py unchanged at 68).Other Python versions/platforms are left to CI. AI assistance: OpenAI Codex assisted with investigation, code, tests and this description. No human review or personal production usage is claimed.