mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-31 19:32:47 +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}`;
|
`${text}`;
|
||||||
}
|
}
|
||||||
const metadata = _.pick(brew, ['title', 'description', 'tags', 'systems', 'renderer', 'theme']);
|
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` +
|
text = `\`\`\`metadata\n` +
|
||||||
`${yaml.dump(metadata)}\n` +
|
`${yaml.dump(metadata)}\n` +
|
||||||
`\`\`\`\n\n` +
|
`\`\`\`\n\n` +
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ const yamlSnippetsToText = (yamlObj)=>{
|
|||||||
if(typeof yamlObj == 'string') return yamlObj;
|
if(typeof yamlObj == 'string') return yamlObj;
|
||||||
|
|
||||||
let snippetsText = '';
|
let snippetsText = '';
|
||||||
for (let snippet of yamlObj.snippets) {
|
|
||||||
|
for (let snippet of yamlObj) {
|
||||||
for (let subSnippet of snippet.subsnippets) {
|
for (let subSnippet of snippet.subsnippets) {
|
||||||
snippetsText = `${snippetsText}\\snippet ${subSnippet.name}\n${subSnippet.gen || ''}\n`;
|
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 metadataSection = brew.text.slice(11, index + 1);
|
||||||
const metadata = yaml.load(metadataSection);
|
const metadata = yaml.load(metadataSection);
|
||||||
Object.assign(brew, _.pick(metadata, ['title', 'description', 'tags', 'systems', 'renderer', 'theme', 'lang']));
|
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);
|
brew.text = brew.text.slice(index + 6);
|
||||||
}
|
}
|
||||||
if(brew.text.startsWith('```css')) {
|
if(brew.text.startsWith('```css')) {
|
||||||
|
|||||||
Reference in New Issue
Block a user