Repository navigation
Description
Prerequisites
- Are you running the latest version of this application?
- Tested with
pymarkdownlnt0.9.40.
- Tested with
- Have you checked the Frequently Asked Questions document?
- Have you simplified the bug report to the essential details?
- Do you have a distinct command line to report?
- Can you clearly state the configuration for this bug report?
- Do you have a minimal document that highlights this bug?
- Are any required files (configuration or Markdown document) attached to the issue?
- No separate files needed: the document is 4 lines (inlined below) and the
configuration is supplied entirely on the command line.
- No separate files needed: the document is 4 lines (inlined below) and the
- Did you perform a cursory search of other issues to look for related issues?
Bug Report
Bug Type
- Assertion Failure
- Documentation
- Scan/Rule not working as expected
- Fix/Rule not working as expected
- Other
Description
With the markdown-tables extension enabled, scanning a document that contains a |
character anywhere inside a nested (sub-)list item aborts the entire run with
BadTokenizationError, caused by ValueError: list.index(x): x not in list in
ParserState.mark_start_information.
The same | at the top list level parses fine. The | does not have to form a table:
the crash also occurs when the pipe is backslash-escaped or inside a code span, which
suggests that table-start detection fires before those cases are considered and then
leaves the container stack inconsistent.
Command Line
pymarkdown --enable-extensions markdown-tables scan repro.mdWith --stack-trace to obtain the traceback below:
pymarkdown --stack-trace --enable-extensions markdown-tables scan repro.mdConfiguration
No configuration file is used. The run is performed in an empty directory so that no
.pymarkdown* or pyproject.toml file is picked up. The only configuration is the
command-line flag --enable-extensions markdown-tables.
The equivalent pyproject.toml configuration reproduces it identically:
[tool.pymarkdown]
extensions.markdown-tables.enabled = trueMarkdown Document
repro.md:
# T
- a
- b | cExpected Behavior
The document is scanned without an unhandled error. - b | c is an ordinary paragraph
inside a nested list item and is not a table (there is no delimiter row), so it should
be treated as text.
Observed Behavior
Unexpected Error(BadTokenizationError): An unhandled error occurred processing the document.
Traceback with --stack-trace:
Traceback (most recent call last):
File ".../pymarkdown/general/tokenized_markdown.py", line 136, in __transform
first_pass_results = self.__parse_blocks_pass(do_add_end_of_stream_token)
File ".../pymarkdown/general/tokenized_markdown.py", line 210, in __parse_blocks_pass
) = self.__parse_blocks_pass_next_line(
File ".../pymarkdown/general/tokenized_markdown.py", line 277, in __parse_blocks_pass_next_line
) = self.__main_pass_did_not_start_close(
File ".../pymarkdown/general/tokenized_markdown.py", line 401, in __main_pass_did_not_start_close
) = ContainerBlockProcessor.parse_line_for_container_blocks(
File ".../pymarkdown/container_blocks/container_block_processor.py", line 135, in parse_line_for_container_blocks
) = ContainerBlockProcessor.__setup(
File ".../pymarkdown/container_blocks/container_block_processor.py", line 58, in __setup
position_marker = ContainerBlockProcessor.__prepare_container_start_variables(
File ".../pymarkdown/container_blocks/container_block_processor.py", line 254, in __prepare_container_start_variables
parser_state.mark_start_information(position_marker)
File ".../pymarkdown/general/parser_state.py", line 449, in mark_start_information
self.__x1_token_index = self.token_document.index(self.__x1_token)
ValueError: list.index(x): x not in list
The above exception was the direct cause of the following exception:
...
File ".../pymarkdown/general/tokenized_markdown.py", line 157, in __transform
raise BadTokenizationError(
"An unhandled error occurred processing the document."
) from this_exception
pymarkdown.general.bad_tokenization_error.BadTokenizationError: An unhandled error occurred processing the document.
Environment
pymarkdownlnt 0.9.40
Python 3.14.7 (MSC v.1944 64 bit (AMD64))
Windows 11
Additional Context
Variants tested
All runs use --enable-extensions markdown-tables unless stated otherwise.
| Input | Result |
|---|---|
- a / - b | c (4-space nested) |
crash |
- a / - b | c (2-space nested) |
crash |
- a / - b \\| c (backslash-escaped pipe) |
crash |
- a / - b `X | Y` c (pipe inside code span) |
crash |
1. a / 1. b | c (ordered list) |
crash |
> - a / > - b | c (list inside block quote) |
crash |
- a / - b | c (pipe at top level only) |
ok |
- a / blank line / - b | c |
ok |
- a / - b | c |
ok |
- a / - b | c with markdown-tables disabled |
ok |
Workarounds
- Replace
|with|. - Insert a blank line before the nested list (this changes the rendering to a loose list).
- Disable
markdown-tables— not viable for projects that contain real tables and rely
onplugins.md013.tables = false, since those table rows then get reported asMD013
line-length violations.
Secondary request: name the failing file
scan -r stops at the first unhandled error and the Unexpected Error(...) message does
not mention which document was being processed. Locating the offending file in a
repository-wide scan required bisecting the corpus. Including the file name (and, if
possible, the line number) in that message would make such reports much easier to produce.
Activity
https://github.com/jackdewinter/pymarkdown/issues/1706
https://github.com/jackdewinter/pymarkdown/issues/1706
https://github.com/jackdewinter/pymarkdown/issues/1706
#1706 (#1715)
jackdewinter commentedon Oct 31, 2026
Most of this was taken care of with Issue 1679, but added extra tests.
Issue 1706 (#1734)
jackdewinter commentedon Nov 1, 2026
this will be in the next release.
https://github.com/jackdewinter/pymarkdown/issues/1706
#1706 (#1738)
jackdewinter commentedon Nov 15, 2026
can you please verify that this is fixed from your end?
pjljvandelaar commentedon Nov 16, 2026
How can I instruct my builder in pyproject.toml to use the beta version with this solution?
I am currently using:
Or, where can I download the beta version of the next release?
glennmatthews commentedon Nov 16, 2026
If I understand things correctly v0.9.42 has the fixes for this issue - trying it out locally I don't see this crash any more, FWIW.
pjljvandelaar commentedon Nov 16, 2026
Bug solved with 0.9.42!
jackdewinter commentedon Nov 17, 2026
verified as no longer reproducible. closing.