Commit b617a4b8 authored by Yusuke Iwaki's avatar Yusuke Iwaki

hide image markdown

parent 5c9c522e
......@@ -21,12 +21,24 @@ public class MarkDown {
*/
public static void apply(TextView textView) {
SpannableString text = new SpannableString(textView.getText());
removeImage(text);
bold(text);
italic(text);
strike(text);
textView.setText(text);
}
private static void removeImage(SpannableString inputText) {
Pattern imagePattern = Pattern.compile(
"!\\[([^\\]]+)\\]\\(((?:http|https):\\/\\/[^\\)]+)\\)", Pattern.MULTILINE);
Matcher matcher = imagePattern.matcher(inputText);
while (matcher.find()) {
inputText.setSpan(new AbsoluteSizeSpan(0),
matcher.start(), matcher.end(),
Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
}
}
private static void bold(SpannableString inputText) {
Pattern boldPattern = Pattern.compile(
"(^|&gt;|[ >_~`])(\\*{1,2})[^\\*\\r\\n]+(\\*{1,2})([<_~`]|\\B|\\b|$)", Pattern.MULTILINE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment