in freemarker-docgen-core/src/main/java/org/freemarker/docgen/core/PrintTextWithDocgenSubstitutionsDirective.java [660:690]
private String fetchOptionalString() throws TemplateException {
int savedCursor = cursor;
skipWS();
char quoteChar = charAt(cursor);
boolean rawString = quoteChar == 'r';
if (rawString) {
if (cursor + 1 < text.length()) {
quoteChar = charAt(cursor + 1);
}
}
if (quoteChar != '"' && quoteChar != '\'') {
cursor = savedCursor;
return null;
}
cursor += rawString ? 2 : 1;
int stringStartIdx = cursor;
while (cursor < text.length() && charAt(cursor) != quoteChar) {
if (!rawString && charAt(cursor) == '\\') {
throw new DocgenTagException(
"Backslash is currently not supported in string literal in Docgen tags, "
+ "except in raw strings (like r\"regular\\s+expression\").", env);
}
cursor++;
}
if (charAt(cursor) != quoteChar) {
throw new DocgenTagException("Unclosed string literal in a Docgen tag.", env);
}
String result = text.substring(stringStartIdx, cursor);
cursor++;
return result;
}