ProfessionalWiki / ExternalContent

MediaWiki extension that allows embedding external content
https://professional.wiki/en/news/external-content
GNU General Public License v2.0
6 stars 4 forks source link

Create absolute links having 'browse' as the default in the parsed document. #16

Closed freephile closed 2 years ago

freephile commented 2 years ago

I created a KH page from bitbucket using the following URL: https://git.pega.io/projects/PS/repos/rulebase-service/browse/README.md Notice browse in the URL.

When importing, all relative links on the page have been replaced with links to bitbucket, but to their raw instead of browse format. So the import created links like this: https://git.pega.io/projects/PS/repos/rulebase-service/raw/README.md Notice raw in the URL.

As a consequence, while the imported .md file renders nicely, following any link leads to raw, unformatted pages. Would it be possible to convert relative links to absolute using the same prefix as in the imported URL (or default to 'browse')?

freephile commented 2 years ago

The file argument obviously needs to be normalized to 'raw' so we can parse the markdown. See line 36 of EmbedUseCase.php

However, the render method in line 58 should probably use a different variant of the normalize routine for content.

freephile commented 2 years ago

Or, looking at more of the code, it looks like UrlExpander.php could be modified with a different $baseUrl, or deeper down in the MarkdownRender.php class where $contentUrl is passed.