Skip to content

fix MarkdownParser : correctly parse link url - #11

Merged
AkramZerarka merged 3 commits into
paperdoc-dev:mainfrom
olivM:fix-MarkdownParser-correctly-parse-link-url
Jul 16, 2026
Merged

fix MarkdownParser : correctly parse link url#11
AkramZerarka merged 3 commits into
paperdoc-dev:mainfrom
olivM:fix-MarkdownParser-correctly-parse-link-url

Conversation

@olivM

@olivM olivM commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

the existing MarkdownParser was only getting styles from a link (forgetting the url ... )

=> fixed

@AkramZerarka

Copy link
Copy Markdown
Contributor

Thanks for the fix, catching the missing URL on Markdown links is definitely needed, and the assertion in test_parse_link looks good.

One issue before merge: TextLink is created for every inline match and passed into bold / italic / strike / code runs as well:

$link = TextLink::make($linkHref, '', $linkText);
// … then attached to bold, italic, code, etc.

For those cases $linkHref is empty, so styled runs get an empty TextLink attached. That pollutes the document model (and could affect renderers that treat any non-null getLink() as a hyperlink).

Could you restrict the link to the link branch only?

} elseif ($linkText !== '') {
    $linkHref = $this->offsetCapture($match, 10);
    $style = TextStyle::make()->setUnderline()->setColor('#2563EB');
    $paragraph->addRun(new TextRun(
        $linkText,
        $style,
        TextLink::make($linkHref),
    ));
}

Happy to merge once that’s updated. Thanks again!

@AkramZerarka
AkramZerarka merged commit ffb08ab into paperdoc-dev:main Jul 16, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants