Repository navigation
fix: escape pipes and header bangs in the mediawiki format - #500
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
A literal | in a cell or header silently split it into extra columns when the table was rendered on a MediaWiki wiki, the same way || and !! act as column separators. Write literal pipes as &astanin#124; (and ! in header rows as &astanin#33;), like the github/pipe formats already escape their separator. Fixes astanin#499 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tablefmt="mediawiki"writes cell and header values raw, so any literal|silently splits the cell into extra columns when the table is rendered on a MediaWiki wiki —||is the column separator in data rows,!!in header rows:The data is silently corrupted. This is the same class the
github/pipeformats already handle for their separator (they renderx | yasx \| y), and the same class prettytable fixed for its own MediaWiki emitter (prettytable #544,|→|).Fixes #499
Fix
_mediawiki_row_with_attrsnow escapes cell values before joining them:|→|everywhere, and!→!in header rows (where!!is the separator). Values without pipes/bangs are byte-identical to before. Newlines inside cells are deliberately untouched — multiline mediawiki support is already on the maintainer's TODO list and would use<br />.Verification
Two new tests (
test_mediawiki_escapes_pipes_in_cells_and_headers,test_mediawiki_escapes_bang_in_headers) fail onmasterand pass with this change; the existingtest_mediawiki/test_mediawiki_headerlesspins are unchanged. Full suite:python3 -m pytest test/→ 351 passed, 17 skipped, zero failures.