Java Code Examples for org.commonmark.internal.util.Escaping#unescapeString()

The following examples show how to use org.commonmark.internal.util.Escaping#unescapeString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MarkwonInlineParser.java    From Markwon with Apache License 2.0 6 votes vote down vote up
/**
 * Attempt to parse link destination, returning the string or null if no match.
 */
@Override
@Nullable
public String parseLinkDestination() {
    int afterDest = LinkScanner.scanLinkDestination(input, index);
    if (afterDest == -1) {
        return null;
    }

    String dest;
    if (peek() == '<') {
        // chop off surrounding <..>:
        dest = input.substring(index + 1, afterDest - 1);
    } else {
        dest = input.substring(index, afterDest);
    }

    index = afterDest;
    return Escaping.unescapeString(dest);
}
 
Example 2
Source File: InlineParserImpl.java    From commonmark-java with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Attempt to parse link destination, returning the string or null if no match.
 */
private String parseLinkDestination() {
    int afterDest = LinkScanner.scanLinkDestination(input, index);
    if (afterDest == -1) {
        return null;
    }

    String dest;
    if (peek() == '<') {
        // chop off surrounding <..>:
        dest = input.substring(index + 1, afterDest - 1);
    } else {
        dest = input.substring(index, afterDest);
    }

    index = afterDest;
    return Escaping.unescapeString(dest);
}
 
Example 3
Source File: InlineParserImpl.java    From 1Rramp-Android with MIT License 5 votes vote down vote up
/**
 * Attempt to parse link destination, returning the string or null if no match.
 */
private String parseLinkDestination() {
    String res = match(LINK_DESTINATION_BRACES);
    if (res != null) { // chop off surrounding <..>:
        if (res.length() == 2) {
            return "";
        } else {
            return Escaping.unescapeString(res.substring(1, res.length() - 1));
        }
    } else {
        int startIndex = index;
        parseLinkDestinationWithBalancedParens();
        return Escaping.unescapeString(input.substring(startIndex, index));
    }
}
 
Example 4
Source File: InlineParserImpl.java    From 1Rramp-Android with MIT License 5 votes vote down vote up
/**
 * Attempt to parse link title (sans quotes), returning the string or null if no match.
 */
private String parseLinkTitle() {
    String title = match(LINK_TITLE);
    if (title != null) {
        // chop off quotes from title and unescape:
        return Escaping.unescapeString(title.substring(1, title.length() - 1));
    } else {
        return null;
    }
}
 
Example 5
Source File: MarkwonInlineParser.java    From Markwon with Apache License 2.0 5 votes vote down vote up
/**
 * Attempt to parse link title (sans quotes), returning the string or null if no match.
 */
@Override
@Nullable
public String parseLinkTitle() {
    int afterTitle = LinkScanner.scanLinkTitle(input, index);
    if (afterTitle == -1) {
        return null;
    }

    // chop off ', " or parens
    String title = input.substring(index + 1, afterTitle - 1);
    index = afterTitle;
    return Escaping.unescapeString(title);
}
 
Example 6
Source File: InlineParserImpl.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * Attempt to parse link title (sans quotes), returning the string or null if no match.
 */
private String parseLinkTitle() {
    int afterTitle = LinkScanner.scanLinkTitle(input, index);
    if (afterTitle == -1) {
        return null;
    }

    // chop off ', " or parens
    String title = input.substring(index + 1, afterTitle - 1);
    index = afterTitle;
    return Escaping.unescapeString(title);
}
 
Example 7
Source File: LinkReferenceDefinitionParser.java    From commonmark-java with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void finishReference() {
    if (!referenceValid) {
        return;
    }

    String d = Escaping.unescapeString(destination);
    String t = title != null ? Escaping.unescapeString(title.toString()) : null;
    definitions.add(new LinkReferenceDefinition(normalizedLabel, d, t));

    label = null;
    referenceValid = false;
    normalizedLabel = null;
    destination = null;
    title = null;
}