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

cite template not parsed #60

Closed sirpy closed 6 years ago

sirpy commented 7 years ago
{{cite web|url=http://www.billboard.com/articles/news/56447/dreamgirls-snares-multiple-golden-globe-nods|title='Dreamgirls' Snares Multiple Golden Globe Nods|date=December 14, 2006|author=Kilday, Gregg|work=[[The Hollywood Reporter]]}}

it's parsed as WtTagExtension, is there some parser to convert this template into it's components?

hannesd commented 7 years ago

I'm confused. That's clearly a template and if I plug this piece of wikitext into the parser I get an WtTemplate AST. Are you using the swc-engine and performing expansion? Could you paste the AST you get (only the relevant part)?

sirpy commented 7 years ago

i'm using the TextConverter example if i put break points in the different visit() methods it stops at WtTagExtension and not WtTemplate

hannesd commented 7 years ago

I'm assuming you are talking about the TextConverter class in sweble-wom3-example-basic version 3.*?

This class has some copy and paste errors (no big problem because it's commented out). The use of type WtTemplate is nonsensical in this context since we are working with WOM nodes and not the AST nodes produced by the parser. The equivalent for WtTemplate in WOM is SwcTransclusion (the tag extension class is SwcTagExtension). If I added the following methods to the TextConverter class:


    public void visit(Wom3Node n)
    {
        // Fallback for all nodes that are not explicitly handled below
        /*write("<");
        write(n.getNodeName());
        write(" />");
        */
        iterate(n);
    }

    public void visit(SwcTransclusion n)
    {
        System.out.println("template");
    }

    public void visit(SwcTagExtension n)
    {
        System.out.println("tagExtension");
    }

The output is "template" which is what I would expect and consider correct. Does this fix your problem?

sirpy commented 7 years ago

i think it does. i will test

On Fri, Jun 23, 2017 at 2:46 PM, Hannes Dohrn notifications@github.com wrote:

I'm assuming you are talking about the TextConverter class in sweble-wom3-example-basic version 3.*?

This class has some copy and paste errors (no big problem because it's commented out). The use of type WtTemplate is nonsensical in this context since we are working with WOM nodes and not the AST nodes produced by the parser. The equivalent for WtTemplate in WOM is SwcTransclusion (the tag extension class is SwcTagExtension). If I added the following methods to the TextConverter class:

public void visit(Wom3Node n) { // Fallback for all nodes that are not explicitly handled below /write("<"); write(n.getNodeName()); write(" />"); / iterate(n); }

public void visit(SwcTransclusion n) { System.out.println("template"); }

public void visit(SwcTagExtension n) { System.out.println("tagExtension"); }

The output is "template" which is what I would expect and consider correct. Does this fix your problem?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sweble/sweble-wikitext/issues/60#issuecomment-310645056, or mute the thread https://github.com/notifications/unsubscribe-auth/AAo9d0K59FxcM1d7uaNWDoytF6t9Ey3Qks5sG6V8gaJpZM4N9cW- .