mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-24 14:12:40 +00:00
A little bit of cleanup and structure flattening
Fixes failed tests.
This commit is contained in:
@@ -177,7 +177,8 @@ const api = {
|
||||
`${text}`;
|
||||
}
|
||||
const metadata = _.pick(brew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme']);
|
||||
metadata.snippets = brewSnippetsToJSON('brew_snippets', brew.snippets, null, false);
|
||||
const snippetsArray = brewSnippetsToJSON('brew_snippets', brew.snippets, null, false).snippets;
|
||||
metadata.snippets = snippetsArray.length > 0 ? snippetsArray : undefined;
|
||||
text = `\`\`\`metadata\n` +
|
||||
`${yaml.dump(metadata)}\n` +
|
||||
`\`\`\`\n\n` +
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
Reference in New Issue
Block a user