clokep / mwcomposerfromhell

Convert parsed MediaWiki wikicode (using mwparserfromhell) to HTML.
ISC License
9 stars 1 forks source link

Convert internal link #1

Closed sh0416 closed 4 years ago

sh0416 commented 4 years ago

First, thanks for implementing this.

It works well :)

The one which isn't convert is the internal link inside the wikitext. It starts with {{ and ends with }}.

Could you implement this component?

I'm not sure but also sfn things could be a flag for internal link.

Thanks.

clokep commented 4 years ago

Could you give a more expansive example of what does work properly?

sh0416 commented 4 years ago

image In that wikitext, {{ }} doesn't work well.. That wikitext comes from the dump database in wikipedia.

clokep commented 4 years ago

That's not an internal link, it is a template, there is some support for templates in mwcomposerfromhell, but it is very manual (and poorly documented).

You should be able to render templates via something like:

# Add custom templates that are necessary.
templates = {
    'Use dmy dates': mwparserfromhell.parse('<the content of this template>'),
}

# Manually create the composer.
composer = mwcomposerfromhell.WikicodeToHtmlComposer(
    base_url=<base URL>, template_store=templates)

# Parse & compose.
wikicode = mwparserfromhell.parse(text)
html = composer.compose(wikicode)

There isn't support for automatically fetching any of the templates or things like that at the moment unfortunately. There are some work-in-progress branches, but nothing is far along enough to share.

sh0416 commented 4 years ago

Thanks for the reply. For now, I just use parsoid. It is slow but accurate.