Search in sources :

Example 1 with TextString

use of com.m2mobi.markymark.item.inline.TextString in project MarkyMark-Android by M2Mobi.

the class InlineConverter method parseContent.

/**
 * TODO: Documentation
 * TODO: consider moving this to a more suitable class?
 */
public List<MarkDownString> parseContent(final String pContent) {
    final List<MarkDownString> markDownStrings = new ArrayList<>();
    String toCheck = pContent;
    while (!toCheck.isEmpty()) {
        MatchedRule matchedRule = findFirstMatch(toCheck);
        if (matchedRule != null) {
            if (matchedRule.mStart > 0) {
                markDownStrings.add(new TextString(toCheck.substring(0, matchedRule.mStart), false));
            }
            String content = toCheck.substring(matchedRule.mStart, matchedRule.mEnd);
            markDownStrings.add(matchedRule.mInlineRule.toMarkDownString(content));
            toCheck = toCheck.substring(matchedRule.mEnd, toCheck.length());
        } else if (!toCheck.isEmpty()) {
            markDownStrings.add(new TextString(toCheck, false));
            break;
        }
    }
    return markDownStrings;
}
Also used : ArrayList(java.util.ArrayList) TextString(com.m2mobi.markymark.item.inline.TextString) MarkDownString(com.m2mobi.markymark.item.inline.MarkDownString) TextString(com.m2mobi.markymark.item.inline.TextString) MarkDownString(com.m2mobi.markymark.item.inline.MarkDownString)

Example 2 with TextString

use of com.m2mobi.markymark.item.inline.TextString in project MarkyMark-Android by M2Mobi.

the class TextDisplayItem method create.

@Override
public Spanned create(final InlineConverter<Spanned> pInlineConverter, final TextString pMarkDownString) {
    final Spannable spannable = SpannableUtils.createSpannable(pInlineConverter, pMarkDownString);
    final String result = StringEscapeUtils.unescapeHtml4(String.valueOf(spannable));
    return new SpannedString(result);
}
Also used : SpannedString(android.text.SpannedString) SpannedString(android.text.SpannedString) TextString(com.m2mobi.markymark.item.inline.TextString) Spannable(android.text.Spannable)

Aggregations

TextString (com.m2mobi.markymark.item.inline.TextString)2 Spannable (android.text.Spannable)1 SpannedString (android.text.SpannedString)1 MarkDownString (com.m2mobi.markymark.item.inline.MarkDownString)1 ArrayList (java.util.ArrayList)1