stripTemplateGuidance function
Strips template-only guidance comments from content before writing the
generated manifest.
The template manifest contains human-readable hints (header block and
inline section labels) that are useful in the committed template but add
noise to the final flatpak-builder manifest in generated/.
Implementation
String stripTemplateGuidance(String content) {
var result = content;
// Strip the multi-line guidance block that follows the "Generated by" line.
result = result.replaceFirst(
RegExp(
'#\n'
'# This is your editable TEMPLATE manifest[^\n]*\n'
'# Run "flutpak generate"[^\n]*\n'
'#\n'
'# SAFE TO EDIT[^\n]*\n'
'# AUTO-INJECTED[^\n]*\n',
),
'',
);
// Strip inline section guidance comments.
for (final re in [
RegExp(r'[ \t]*# Sandbox permissions[^\n]*\n'),
RegExp(r'[ \t]*# Build steps — review[^\n]*\n'),
]) {
result = result.replaceAll(re, '');
}
return result;
}