mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-11-25 18:32:15 -05:00
Fix mirc color bug by changing the tagsoup schema and making the font tag restartable.
This commit is contained in:
parent
624f8c5014
commit
59c70a750d
@ -20,8 +20,10 @@ import java.io.IOException;
|
|||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.ccil.cowan.tagsoup.HTMLModels;
|
||||||
import org.ccil.cowan.tagsoup.HTMLSchema;
|
import org.ccil.cowan.tagsoup.HTMLSchema;
|
||||||
import org.ccil.cowan.tagsoup.Parser;
|
import org.ccil.cowan.tagsoup.Parser;
|
||||||
|
import org.ccil.cowan.tagsoup.Schema;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
import org.xml.sax.ContentHandler;
|
import org.xml.sax.ContentHandler;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
@ -96,6 +98,7 @@ public class Html2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Html2() { }
|
private Html2() { }
|
||||||
|
private static HTMLSchema schema = new HTMLSchema();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns displayable styled text from the provided HTML string.
|
* Returns displayable styled text from the provided HTML string.
|
||||||
@ -115,7 +118,7 @@ public class Html2 {
|
|||||||
* necessary.
|
* necessary.
|
||||||
*/
|
*/
|
||||||
private static class HtmlParser {
|
private static class HtmlParser {
|
||||||
private static final HTMLSchema schema = new HTMLSchema();
|
private final static HTMLSchema schema = new HTMLSchema();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -130,8 +133,10 @@ public class Html2 {
|
|||||||
public static Spanned fromHtml(String source, ImageGetter imageGetter,
|
public static Spanned fromHtml(String source, ImageGetter imageGetter,
|
||||||
TagHandler tagHandler) {
|
TagHandler tagHandler) {
|
||||||
Parser parser = new Parser();
|
Parser parser = new Parser();
|
||||||
|
// Make the font tag restartable
|
||||||
|
schema.elementType("font", Schema.M_PCDATA|HTMLModels.M_INLINE, HTMLModels.M_INLINE|HTMLModels.M_NOLINK, Schema.F_RESTART);
|
||||||
try {
|
try {
|
||||||
parser.setProperty(Parser.schemaProperty, HtmlParser.schema);
|
parser.setProperty(Parser.schemaProperty, schema);
|
||||||
} catch (org.xml.sax.SAXNotRecognizedException e) {
|
} catch (org.xml.sax.SAXNotRecognizedException e) {
|
||||||
// Should not happen.
|
// Should not happen.
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
@ -408,11 +413,11 @@ class HtmlToSpannedConverter implements ContentHandler {
|
|||||||
1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f,
|
1.5f, 1.4f, 1.3f, 1.2f, 1.1f, 1f,
|
||||||
};
|
};
|
||||||
|
|
||||||
private String mSource;
|
private final String mSource;
|
||||||
private XMLReader mReader;
|
private final XMLReader mReader;
|
||||||
private SpannableStringBuilder mSpannableStringBuilder;
|
private final SpannableStringBuilder mSpannableStringBuilder;
|
||||||
private Html2.ImageGetter mImageGetter;
|
private final Html2.ImageGetter mImageGetter;
|
||||||
private Html2.TagHandler mTagHandler;
|
private final Html2.TagHandler mTagHandler;
|
||||||
|
|
||||||
public HtmlToSpannedConverter(
|
public HtmlToSpannedConverter(
|
||||||
String source, Html2.ImageGetter imageGetter, Html2.TagHandler tagHandler,
|
String source, Html2.ImageGetter imageGetter, Html2.TagHandler tagHandler,
|
||||||
@ -867,7 +872,7 @@ class HtmlToSpannedConverter implements ContentHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class Header {
|
private static class Header {
|
||||||
private int mLevel;
|
private final int mLevel;
|
||||||
|
|
||||||
public Header(int level) {
|
public Header(int level) {
|
||||||
mLevel = level;
|
mLevel = level;
|
||||||
|
Loading…
Reference in New Issue
Block a user