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

text/rtf -> text/html: Strikethrough formatting not being converted #3

Open
Robert-Rendell opened this issue Dec 8, 2020 · 0 comments

Comments

@Robert-Rendell
Copy link

Robert-Rendell commented Dec 8, 2020

Given the following code:

public class RTF2HTMLConverterJEditorPane implements RTF2HTMLConverter {
	public static final RTF2HTMLConverter INSTANCE = new RTF2HTMLConverterJEditorPane();
	
	private RTF2HTMLConverterJEditorPane() {}

	@NotNull
	public String rtf2html(@NotNull final String rtf) {
		final JEditorPane p = new JEditorPane();
		p.setContentType("text/rtf");
		final EditorKit kitRtf = p.getEditorKitForContentType("text/rtf");
		try {
			kitRtf.read(new StringReader(rtf), p.getDocument(), 0);
			final Writer writer = new StringWriter();
			final EditorKit editorKitForContentType = p.getEditorKitForContentType("text/html");
			editorKitForContentType.write(writer, p.getDocument(), 0, p.getDocument().getLength());
			return writer.toString();
		} catch (IOException | BadLocationException e) {
			throw new RTF2HTMLException("Could not convert RTF to HTML.", e);
		}
	}
}

The following RTF string:

\strike - strikethrough\strike

I don't see strikethrough formatting being converted to HTML.

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

No branches or pull requests

1 participant