RichTextNode constructor
RichTextNode({
- required String path,
- required String rawPath,
- required Map<
String, String> modifiers, - required I18nLocale locale,
- required Map<
String, FormatTypeInfo> types, - required String raw,
- required String? comment,
- required bool shouldEscape,
- required bool handleTypes,
- required StringInterpolation interpolation,
- required CaseStyle? paramCase,
- Map<
String, Set< ? linkParamMap,String> >
Implementation
RichTextNode({
required super.path,
required super.rawPath,
required super.modifiers,
required super.locale,
required super.types,
required super.raw,
required super.comment,
required super.shouldEscape,
required super.handleTypes,
required super.interpolation,
required super.paramCase,
Map<String, Set<String>>? linkParamMap,
}) {
final rawParsedResult = _parseInterpolation(
locale: locale,
types: types,
raw: shouldEscape ? _escapeContent(raw, interpolation) : raw,
interpolation: interpolation,
defaultType: 'ignored',
// types are ignored
paramCase: null, // param case will be applied later
digestParameter: false,
);
_params = <String>{};
for (final key in rawParsedResult.params.keys) {
final parsedParam = parseParamWithArg(
rawParam: key,
paramCase: paramCase,
);
_params.add(parsedParam.paramName);
_paramTypeMap[parsedParam.paramName] =
parsedParam.arg == null ? 'InlineSpan' : 'InlineSpanBuilder';
}
if (linkParamMap != null) {
_params.addAll(linkParamMap.values.expand((e) => e));
}
_links = {};
_spans = _splitWithMatchAndNonMatch(
rawParsedResult.parsedContent,
RegexUtils.argumentsDartRegex,
onNonMatch: (text) {
final parsedLinksResult = _parseLinks(
input: text,
linkParamMap: linkParamMap,
);
_links.addAll(parsedLinksResult.links);
return LiteralSpan(
literal: parsedLinksResult.parsedContent,
isConstant: parsedLinksResult.links.isEmpty,
links: parsedLinksResult.links,
);
},
onMatch: (match) {
final parsed = parseParamWithArg(
rawParam: (match.group(1) ?? match.group(2))!,
paramCase: paramCase,
);
final parsedArg = parsed.arg;
if (parsedArg != null) {
final parsedLinksResult = _parseLinks(
input: parsedArg,
linkParamMap: linkParamMap,
);
_links.addAll(parsedLinksResult.links);
return FunctionSpan(
functionName: parsed.paramName,
arg: parsedLinksResult.parsedContent,
links: parsedLinksResult.links,
);
} else {
return VariableSpan(parsed.paramName);
}
},
).toList();
}