sweble / sweble-wikitext

The Sweble Wikitext Components module provides a parser for MediaWiki's wikitext and an engine trying to emulate the behavior of a MediaWiki.
http://sweble.org/sites/swc-devel/develop-latest/tooling/sweble/sweble-wikitext
70 stars 27 forks source link

FmtNotYetImplementedError when visiting WtExternalLink #62

Closed christiandmiddel closed 7 years ago

christiandmiddel commented 7 years ago

When translating the wiki text from wikipedia "Böblingen" article I experienced an FmtNotYetImplementedError

from org.sweble.wikitext.engine.output.HtmlRenderer public void visit(WtExternalLink n)

I am working on the complete August 1st dump on Wikipedia, and the article "Böblingen" is just a sample of that problem.

Do you have explanation for the case, so I could possibly help in the resolution?

hannesd commented 7 years ago

It's been a while since I've touched this code. If I'm not mistaken the respective code is for an external link without explicit title, e.g.: [[http://foo.bar]]. If I remember correctly this type of link is rendered in Wikipedia as some sort of footnote [x] with the actual link located at the bottom of the rendered page.

For some reason I have not implemented this back then, can't say why now. If you want to help out I'd be happy to accept a pull request that adds this missing piece.

christiandmiddel commented 7 years ago

Exactly right, I double checked the "Böblingen" article and yes the problem is caused by: ...Grillplatz befindet.[http://www.szbz.de/nachrichten/artikel/detail/weite-saetze-und-harte-landungen-9-2-2013/]... I also looked into the actual rendering in mediawiki itself and it seems like it is rendered with a sequential number instead of the missing title, like: [1] or [2] So I would implement a counter in org.sweble.wikitext.engine.output.HtmlRenderer assuming the intended use of the renderer is to have a new instance per page. Is that fine with you?

hannesd commented 7 years ago

Sounds good! Though a counter alone is not enough. To render the list of URLs including their numbers at the end of the article you also need a collection of all the URLs you have encountered (or a map).

christiandmiddel commented 7 years ago

Just to confirm, in the "Böblingen" article the links that are rendered at the very end as "Einzelnachweis", are triggered by raw text such as:

<ref name="Mercade1">{{Internetquelle | url=http://www.stuttgarter-nachrichten.de/inhalt.mercaden-boeblingen-wird-zur-einkaufsstadt.2c8fe961-8326-4ea7-8821-b5d7d851dfb0.html | titel=Mercaden: Böblingen (…) | autor=Ulrich Hanselmann | hrsg=stuttgarter-nachrichten.de | datum=2012-06-22 | zugriff=2014-01-16}}</ref>

As far as I can see none of these are currently rendered to the "Einzelnachweis" section, nor mentioned in the original position. It also does not trigger any exception.

Here we might have identified an additional enhancement request. That I am not sure.

The case I am talking about simply renders into [1] in wikipedia itself which is not further referenced anywhere else.

Could you please confirm?

christiandmiddel commented 7 years ago

You can double-check in Wikipedia Böblingen article

Case 1: The citation references - Search for "Mercaden" Case 2: My problem - Search for "Grillplatz"

hannesd commented 7 years ago

That's correct. My recollection of MediaWiki's behavior was wrong, as can be seen here: https://www.mediawiki.org/wiki/Help:Links#External_links (Sweble is supposed to emulate MediaWiki, Wikipedia could have installed an extension that changes this behavior). Your initial approach is therefore correct.

I don't think I ever added support for the tag. So this would indeed be another feature request.

christiandmiddel commented 7 years ago

What branch should push to?

hannesd commented 7 years ago

I'm assuming you're working off the develop branch (v3.x). Please use that branch in your pull request.

christiandmiddel commented 7 years ago

I am unable to push remote: Permission to sweble/sweble-wikitext.git denied to christiandmiddel

christiandmiddel commented 7 years ago

Sorry, confusion on my end, I am not working too often against github ;-) Pull request is in...

hannesd commented 7 years ago

Thanks for the patch! Merged in a7eb726e4f217410dbedca4248c0967dd6c14f71