0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 16:22:44 +00:00

A little bit of cleanup and structure flattening

Fixes failed tests.
This commit is contained in:
David Bolack
2025-04-08 20:29:32 -05:00
parent 9f56d100aa
commit c6cd6e9864
2 changed files with 5 additions and 3 deletions

View File

@@ -76,7 +76,8 @@ const yamlSnippetsToText = (yamlObj)=>{
if(typeof yamlObj == 'string') return yamlObj;
let snippetsText = '';
for (let snippet of yamlObj.snippets) {
for (let snippet of yamlObj) {
for (let subSnippet of snippet.subsnippets) {
snippetsText = `${snippetsText}\\snippet ${subSnippet.name}\n${subSnippet.gen || ''}\n`;
}
@@ -91,7 +92,7 @@ const splitTextStyleAndMetadata = (brew)=>{
const metadataSection = brew.text.slice(11, index + 1);
const metadata = yaml.load(metadataSection);
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
brew.snippets = yamlSnippetsToText(_.pick(metadata, ['snippets']).snippets);
brew.snippets = yamlSnippetsToText(_.pick(metadata, ['snippets']).snippets || '');
brew.text = brew.text.slice(index + 6);
}
if(brew.text.startsWith('```css')) {