mirror of
https://github.com/k0shk0sh/FastHub.git
synced 2025-12-08 19:05:54 +00:00
Previously the feed would show the markdown in comments, but wouldn't format it. This fixes that.
39 lines
1.1 KiB
Java
Executable File
39 lines
1.1 KiB
Java
Executable File
package com.zzhoujay.markdown;
|
|
|
|
import android.text.Html;
|
|
import android.text.Spannable;
|
|
import android.text.Spanned;
|
|
import android.text.style.CharacterStyle;
|
|
import android.widget.TextView;
|
|
|
|
import com.zzhoujay.markdown.parser.StyleBuilderImpl;
|
|
|
|
import java.io.IOException;
|
|
|
|
/**
|
|
* Created by zhou on 16-6-25.
|
|
* Markdown解析器
|
|
*/
|
|
public class MarkDown {
|
|
|
|
public static Spanned fromMarkdown(String source, Html.ImageGetter imageGetter, TextView textView) {
|
|
MarkDownParser parser = new MarkDownParser(source, new StyleBuilderImpl(textView, imageGetter));
|
|
try {
|
|
return parser.parse();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public static Spanned fromMarkdown(String source, TextView textView, int codeColor, int headerColor, Html.ImageGetter imageGetter) {
|
|
MarkDownParser parser = new MarkDownParser(source, new StyleBuilderImpl(textView, codeColor, headerColor, imageGetter));
|
|
try {
|
|
return parser.parse();
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return null;
|
|
}
|
|
}
|