lruiz/MarkdownPapers

Incorrect generation of HTML when entities are positioned inside emphasis underscores

uriahcarpenter opened this issue · 3 comments

This test case shows incorrect HTML generation when using entities positioned inside emphasis underscores.

__Bold™__

should appear as:

Bold™

import java.io.IOException;
import java.io.StringReader;
import java.io.StringWriter;

import org.junit.Test;
import org.tautua.markdownpapers.Markdown;
import org.tautua.markdownpapers.parser.ParseException;

import static junit.framework.Assert.assertEquals;

public class MarkdownTest
{

    @Test
    public void testIncorrectEntityTransform()
    {
        // incorrectly generates:
        //            <p>__Bold&trade;__</p>
        assertEquals("<p><strong>Bold&trade;</strong></p>\n", transform("__Bold&trade;__"));
    }

    @Test
    public void testNoEntityTransform()
    {
        assertEquals("<p><strong>Bold</strong></p>\n", transform("__Bold__"));
    }

    @Test
    public void testEntityNotWrappedTransform()
    {
        assertEquals("<p><strong>Bold</strong>&trade;<em>Italics</em></p>\n", transform("__Bold__&trade;_Italics_"));
    }

    private String transform(String in)
    {
        StringWriter out = new StringWriter();
        Markdown md = new Markdown();

        try
        {
            md.transform(new StringReader(in), out);
        }
        catch (ParseException e)
        {
            throw new RuntimeException("Error parsing Markdown", e);
        }

        return out.toString();        
    }

}

Using markdownpapers-core 1.2.7

I'm sorry, not yet closed

Fixed on version 1.3.0, It will be available soon through Maven repository

Confirmed that 1.3.0 fixes my specific use case. Thanks!

You have, by far, the best Java Markdown library.