Search in sources :

Example 1 with MarkDownString

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

the class BoldRule method toMarkDownString.

@Override
public MarkDownString toMarkDownString(String pContent) {
    Matcher matcher = getRegex().matcher(pContent);
    String content = "";
    if (matcher.find()) {
        content = matcher.group(2);
    }
    return new BoldString(content, true);
}
Also used : Matcher(java.util.regex.Matcher) BoldString(com.m2mobi.markymarkcommon.markdownitems.inline.BoldString) BoldString(com.m2mobi.markymarkcommon.markdownitems.inline.BoldString) MarkDownString(com.m2mobi.markymark.item.inline.MarkDownString)

Example 2 with MarkDownString

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

the class ItalicRule method toMarkDownString.

@Override
public MarkDownString toMarkDownString(String pContent) {
    Matcher matcher = getRegex().matcher(pContent);
    String content = "";
    if (matcher.find()) {
        content = matcher.group(2);
    }
    return new ItalicString(content, true);
}
Also used : Matcher(java.util.regex.Matcher) ItalicString(com.m2mobi.markymarkcommon.markdownitems.inline.ItalicString) MarkDownString(com.m2mobi.markymark.item.inline.MarkDownString) ItalicString(com.m2mobi.markymarkcommon.markdownitems.inline.ItalicString)

Example 3 with MarkDownString

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

the class StrikeRule method toMarkDownString.

@Override
public MarkDownString toMarkDownString(final String pContent) {
    Matcher matcher = getRegex().matcher(pContent);
    String content = "";
    if (matcher.find()) {
        content = matcher.group(1);
    }
    return new StrikeString(content, true);
}
Also used : Matcher(java.util.regex.Matcher) StrikeString(com.m2mobi.markymarkcommon.markdownitems.inline.StrikeString) MarkDownString(com.m2mobi.markymark.item.inline.MarkDownString) StrikeString(com.m2mobi.markymarkcommon.markdownitems.inline.StrikeString)

Example 4 with MarkDownString

use of com.m2mobi.markymark.item.inline.MarkDownString 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)

Aggregations

MarkDownString (com.m2mobi.markymark.item.inline.MarkDownString)4 Matcher (java.util.regex.Matcher)3 TextString (com.m2mobi.markymark.item.inline.TextString)1 BoldString (com.m2mobi.markymarkcommon.markdownitems.inline.BoldString)1 ItalicString (com.m2mobi.markymarkcommon.markdownitems.inline.ItalicString)1 StrikeString (com.m2mobi.markymarkcommon.markdownitems.inline.StrikeString)1 ArrayList (java.util.ArrayList)1