fix: preserve inline hyperlinks in article markdown#44
Merged
jackwener merged 3 commits intopublic-clis:mainfrom Mar 21, 2026
Merged
fix: preserve inline hyperlinks in article markdown#44jackwener merged 3 commits intopublic-clis:mainfrom
jackwener merged 3 commits intopublic-clis:mainfrom
Conversation
Contributor
Author
|
@jackwener |
…entheses in URLs - Early return when no entityRanges (skip unnecessary processing) - Escape [ and ] in link labels to prevent nested bracket issues - Encode ) in URLs as %29 to prevent malformed markdown links (e.g. Wikipedia) - Add 3 new test cases for the above edge cases
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.
Summary
LINKentities when parsing Twitter/X article Draft.js blocksProblem
twitter article --markdowncurrently keeps article text, images, and embedded markdown blocks, but it drops inline hyperlinks carried in Draft.jsentityRanges/entityMap.That means linked phrases such as
reading our docsorSkill Creatorare emitted as plain text, so the article loses important context and references when exported.Fix
Add
_render_article_text_block()intwitter_cli/parser.pyto:entityRangesLINKentities from the normalizedentityMap[label](url)Test plan
Automated
pytest -q tests/test_client.py tests/test_cli.py tests/test_serialization.py121 passed in 5.89spytest -q220 passed, 6 deselected in 4.04sManual
twitter article https://x.com/trq212/status/2033949937936085378 --markdown[reading our docs](https://code.claude.com/docs/en/skills)[new Skilljar on Agent Skills](https://anthropic.skilljar.com/introduction-to-agent-skills)[Skill Creator](https://claude.com/blog/improving-skill-creator-test-measure-and-refine-agent-skills)[frontend design skill](https://github.com/anthropics/skills/blob/main/skills/frontend-design/SKILL.md)[documentation](https://code.claude.com/docs/en/plugin-marketplaces)[example code here](https://gist.github.com/ThariqS/24defad423d701746e23dc19aace4de5)Notes
The article used for validation was: