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

Markdown marked as code is rendered #54

Closed malberts closed 8 months ago

malberts commented 8 months ago

Follow-up to #53 and #42

In LocalSettings, set: $wgExternalContentRenderMarkdownByDefault = true; (or remove the line to use the default true).

Use this wikitext in a page: {{#embed:https://github.com/ProfessionalWiki/ExternalContent|lang=md}}

The Markdown is now rendered, but it should be in a code block: Screenshot_20231030_134331

malberts commented 8 months ago

Additionally, even non-Markdown URLs get rendered as Markdown.

Example with the same config as above:

{{#embed:https://github.com/ProfessionalWiki/ExternalContent/blob/master/src/Adapters/EmbedPresenter/UsageTracker.php}}

{{#embed:https://github.com/ProfessionalWiki/ExternalContent/blob/master/src/Adapters/EmbedPresenter/UsageTracker.php|lang=php}}

Screenshot_20231030_134552

myousuffazal commented 8 months ago

For my clarity, please clarify:

From what I understood from https://github.com/ProfessionalWiki/ExternalContent/issues/37 If $wgExternalContentRenderMarkdownByDefault === true then all files will be rendered as Markdown by default If $wgExternalContentRenderMarkdownByDefault === false then all files will be rendered as Code by default, unless render parameter is defined

Now, what I've missed is if the lang parameter is defined, it should render as code regardless.

Am I correct?

malberts commented 8 months ago

If $wgExternalContentRenderMarkdownByDefault === true then all files will be rendered as Markdown by default

Only if it is a Markdown file. It doesn't make sense to render non-Markdown files. The intention with this config is to maintain backward compatibility with version 1.x where only Markdown was originally supported and therefore it was the default.

If $wgExternalContentRenderMarkdownByDefault === false then all files will be rendered as Code by default, unless render parameter is defined

Yes.

Now, what I've missed is if the lang parameter is defined, it should render as code regardless.

Yes.

myousuffazal commented 8 months ago

Fixed in https://github.com/ProfessionalWiki/ExternalContent/pull/55