Repository navigation
Description
Prerequisites
- Are you running the latest version of this application?
- Have you checked the Frequently Asked Questions document?
- Did you perform a cursory search of other issues to look for related issues?
- 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?
Bug Report
Bug Type
- Assertion Failure
- Documentation
- Scan/Rule not working as expected
- Fix/Rule not working as expected
- Other: Unhandled exception, extension-specific
Description
With the markdown-tables extension enabled:
Tokenization crashes with an unhandled ValueError whenever a list item that contains a | character starts on the line immediately after a paragraph line. In other words, the list interrupts the paragraph with no blank line between them.
The crash is not mitigated by having MD032 (blanks-around-lists) enabled.
Practical Impact
- text with a | pipe directly under a paragraph is fairly common in tech documentation. For example, a lead-in sentence followed by a bulleted list of shell commands .
In my own existing documentation set of ~110 files, 8 files hit this exception. Because the pipe cannot be escaped away, each case required restructuring the Markdown to avoid the crash.
Possibly Related Issue
- #1482 "Parsing error" (open):
Also amark_start_information/ container-stateBadTokenizationError, but caused by a block quote nested 4+ levels inside a list. No pipes, markdown-tables extension not required.
Specifics
Environment
| Item | Value |
|---|---|
| pymarkdownlnt | 0.9.39 (current latest on PyPI) |
| Python | 3.14.6 |
| OS | macOS 26.6.2, arm64 |
| Extension | markdown-tables enabled |
Minimal Reproduction
Two lines of Markdown are enough:
paragraph text
- a | bCommand:
uv run pymarkdown --enable-extensions markdown-tables scan markdown-tables-bad-tokenization.mdResult:
WARNING:pymarkdown.main:Unexpected Error(BadTokenizationError): An unhandled error occurred processing the document.
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 136, in __transform
first_pass_results = self.__parse_blocks_pass(do_add_end_of_stream_token)
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 210, in __parse_blocks_pass
) = self.__parse_blocks_pass_next_line(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
next_line_in_document,
^^^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
ignore_table_start,
^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 277, in __parse_blocks_pass_next_line
) = self.__main_pass_did_not_start_close(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
...<3 lines>...
ignore_table_start,
^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 401, in __main_pass_did_not_start_close
) = ContainerBlockProcessor.parse_line_for_container_blocks(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
...<4 lines>...
0,
^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 135, in parse_line_for_container_blocks
) = ContainerBlockProcessor.__setup(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
position_marker,
^^^^^^^^^^^^^^^^
grab_bag,
^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 58, in __setup
position_marker = ContainerBlockProcessor.__prepare_container_start_variables(
parser_state,
position_marker,
grab_bag,
)
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 254, in __prepare_container_start_variables
parser_state.mark_start_information(position_marker)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.14/site-packages/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:
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/pymarkdown/main.py", line 474, in main
else self.__scan_files_if_no_errors(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
args,
^^^^^
...<2 lines>...
did_error_scanning_files,
^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/main.py", line 398, in __scan_files_if_no_errors
fsh.process_files_to_scan(
~~~~~~~~~~~~~~~~~~~~~~~~~^
args, use_standard_in, files_to_scan, self.__string_to_scan
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 125, in process_files_to_scan
did_succeed = self.__scan_specific_file(
next_file, next_file, per_file_disabled_identifiers
)
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 228, in __scan_specific_file
self.__scan_file(
~~~~~~~~~~~~~~~~^
source_provider, next_file_name, per_file_disabled_identifiers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 257, in __scan_file
actual_tokens = self.__tokenizer.transform_from_provider(
source_provider, do_add_end_of_stream_token=True
)
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 102, in transform_from_provider
return self.__transform(do_add_end_of_stream_token)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.14/site-packages/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.
Unexpected Error(BadTokenizationError): An unhandled error occurred processing the document.
kbluck@Kevins-Mac-Studio yt-ninjascript % uv run pymarkdown scan markdown-tables-bad-tokenization.md
WARNING:pymarkdown.main:Unexpected Error(BadTokenizationError): An unhandled error occurred processing the document.
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 136, in __transform
first_pass_results = self.__parse_blocks_pass(do_add_end_of_stream_token)
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 210, in __parse_blocks_pass
) = self.__parse_blocks_pass_next_line(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
next_line_in_document,
^^^^^^^^^^^^^^^^^^^^^^
...<5 lines>...
ignore_table_start,
^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 277, in __parse_blocks_pass_next_line
) = self.__main_pass_did_not_start_close(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
...<3 lines>...
ignore_table_start,
^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 401, in __main_pass_did_not_start_close
) = ContainerBlockProcessor.parse_line_for_container_blocks(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
...<4 lines>...
0,
^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 135, in parse_line_for_container_blocks
) = ContainerBlockProcessor.__setup(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
parser_state,
^^^^^^^^^^^^^
position_marker,
^^^^^^^^^^^^^^^^
grab_bag,
^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 58, in __setup
position_marker = ContainerBlockProcessor.__prepare_container_start_variables(
parser_state,
position_marker,
grab_bag,
)
File ".venv/lib/python3.14/site-packages/pymarkdown/container_blocks/container_block_processor.py", line 254, in __prepare_container_start_variables
parser_state.mark_start_information(position_marker)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.14/site-packages/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:
Traceback (most recent call last):
File ".venv/lib/python3.14/site-packages/pymarkdown/main.py", line 474, in main
else self.__scan_files_if_no_errors(
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
args,
^^^^^
...<2 lines>...
did_error_scanning_files,
^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/main.py", line 398, in __scan_files_if_no_errors
fsh.process_files_to_scan(
~~~~~~~~~~~~~~~~~~~~~~~~~^
args, use_standard_in, files_to_scan, self.__string_to_scan
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 125, in process_files_to_scan
did_succeed = self.__scan_specific_file(
next_file, next_file, per_file_disabled_identifiers
)
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 228, in __scan_specific_file
self.__scan_file(
~~~~~~~~~~~~~~~~^
source_provider, next_file_name, per_file_disabled_identifiers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
)
^
File ".venv/lib/python3.14/site-packages/pymarkdown/file_scan_helper.py", line 257, in __scan_file
actual_tokens = self.__tokenizer.transform_from_provider(
source_provider, do_add_end_of_stream_token=True
)
File ".venv/lib/python3.14/site-packages/pymarkdown/general/tokenized_markdown.py", line 102, in transform_from_provider
return self.__transform(do_add_end_of_stream_token)
~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.14/site-packages/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.
Unexpected Error(BadTokenizationError): An unhandled error occurred processing the document.
Activity
jackdewinter commentedon Sep 16, 2026
have a fix for this and preventatives working through the system
https://github.com/jackdewinter/pymarkdown/issues/1679
#1679 (#1695)
jackdewinter commentedon Sep 16, 2026
committed, and will be in next release
jackdewinter commentedon Nov 15, 2026
can you please verify that this is fixed from your end?
jackdewinter commentedon Dec 2, 2026
closing after no response