in packages/code_excerpter/lib/src/excerpter.dart [33:70]
Excerpter weave() {
final lines = content.split(eol);
// Collect the full file in case we need it.
_excerptStart(fullFileKey);
for (_lineIdx = 0; _lineIdx < lines.length; _lineIdx++) {
_processLine();
}
// Drop trailing blank lines for all excerpts.
// Normalize indentation for all but the full file.
for (final entry in excerpts.entries) {
final name = entry.key;
final excerpt = entry.value;
dropTrailingBlankLines(excerpt);
_dropTrailingPlaster(excerpt);
if (name == fullFileKey) continue;
excerpts[name] = maxUnindent(excerpt).toList();
}
// Final adjustment to excerpts relative to fullFileKey:
if (!containsDirectives) {
// No directives? Don't report any excerpts
excerpts.clear();
} else if (excerpts.containsKey(defaultRegionKey)) {
// There was an explicitly named default region. Drop fullFileKey.
excerpts.remove(fullFileKey);
} else {
// Report fullFileKey excerpt for defaultRegionKey
final fullFileExcerpt = excerpts.remove(fullFileKey);
if (fullFileExcerpt != null) {
excerpts[defaultRegionKey] = fullFileExcerpt;
}
}
return this;
}