mirror of
https://github.com/leanote/leanote-android.git
synced 2025-10-17 07:54:24 +00:00
fix #42
This commit is contained in:
@@ -25,6 +25,7 @@ import org.houxg.leamonax.model.NoteFile;
|
||||
import org.houxg.leamonax.model.Notebook;
|
||||
import org.houxg.leamonax.service.NoteFileService;
|
||||
import org.houxg.leamonax.utils.FileUtils;
|
||||
import org.houxg.leamonax.utils.HtmlUtils;
|
||||
import org.houxg.leamonax.utils.TimeUtils;
|
||||
import org.houxg.leamonax.widget.NoteList;
|
||||
|
||||
@@ -237,9 +238,9 @@ public class NoteAdapter extends RecyclerView.Adapter<NoteAdapter.NoteHolder> {
|
||||
|
||||
private CharSequence getHighlightedText(String text) {
|
||||
if (mTitleHighlight == null) {
|
||||
return text;
|
||||
return HtmlUtils.delHTMLTag(text);
|
||||
}
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(text);
|
||||
SpannableStringBuilder builder = new SpannableStringBuilder(HtmlUtils.delHTMLTag(text));
|
||||
Matcher matcher = mTitleHighlight.matcher(text);
|
||||
int color = 0xFFFDD835;
|
||||
while (matcher.find()) {
|
||||
|
@@ -12,6 +12,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class HtmlUtils {
|
||||
|
||||
@@ -191,4 +193,24 @@ public class HtmlUtils {
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
public static String delHTMLTag(String htmlStr){
|
||||
String regEx_script="<script[^>]*?>[\\s\\S]*?<\\/script>"; //定义script的正则表达式
|
||||
String regEx_style="<style[^>]*?>[\\s\\S]*?<\\/style>"; //定义style的正则表达式
|
||||
String regEx_html="<[^>]+>"; //定义HTML标签的正则表达式
|
||||
|
||||
Pattern p_script=Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_script=p_script.matcher(htmlStr);
|
||||
htmlStr=m_script.replaceAll(""); //过滤script标签
|
||||
|
||||
Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_style=p_style.matcher(htmlStr);
|
||||
htmlStr=m_style.replaceAll(""); //过滤style标签
|
||||
|
||||
Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE);
|
||||
Matcher m_html=p_html.matcher(htmlStr);
|
||||
htmlStr=m_html.replaceAll(""); //过滤html标签
|
||||
|
||||
return htmlStr.trim(); //返回文本字符串
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/primary_text_light"
|
||||
android:textSize="20sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:text="Leanote API" />
|
||||
|
||||
|
@@ -28,6 +28,8 @@
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/primary_text_light"
|
||||
android:textSize="20sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:layout_marginBottom="4dp"
|
||||
tools:text="Leanote API" />
|
||||
|
||||
|
@@ -23,6 +23,8 @@
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@color/primary_text_light"
|
||||
android:textSize="20sp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
tools:text="Leanote API" />
|
||||
|
||||
</LinearLayout>
|
||||
|
Reference in New Issue
Block a user