Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

list not finishing with character throws exception #8

Open
GoogleCodeExporter opened this issue Apr 11, 2015 · 0 comments
Open

list not finishing with character throws exception #8

GoogleCodeExporter opened this issue Apr 11, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. use MainClass.java from trunk
2. set wikitext = "* [[X]], [[Y]]" + "\nZ";
3. run app

What is the expected output? What do you see instead?
expected: <div><ul><li><a href="SMARTLINK:X">X</a>, <a 
href="SMARTLINK:Y">Y</a></li></ul><p>Z</p></div>
(NB SMARTLINK is my dummy SmartLinkResolver)
instead:
Exception in thread "main" java.lang.NullPointerException
    at be.devijver.wikipedia.parser.ast.UnorderedListItem.toString(UnorderedListItem.java:16)

Please provide any additional information below.

This exception is thrown when there is no character at the end of the list
I copy/pasting here my patch.

in MarkupParser.java method public Content[] parseContentList()

TRUNK VERSION

if (currentCharacter == '\n') {
    if (!characters.isEmpty()) {
        contentList.add(new Characters(asString(characters)));
        return (Content[])contentList.toArray(new Content[contentList.size()]);
    } else {
        return null;
    }
}


PATCHED VERSION

if (currentCharacter == '\n') 
{
    if (!characters.isEmpty()) 
        contentList.add(new Characters(asString(characters)));                  
    if (!contentList.isEmpty())
        return (Content[]) contentList
                .toArray(new Content[contentList.size()]);                  
    return null;                    
} 


Original issue reported on code.google.com by [email protected] on 29 Jul 2010 at 8:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant