mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-08 11:52:44 +00:00
WOrking snippets insertion from local.
This commit is contained in:
@@ -35,12 +35,12 @@ const brewSnippetsToJSON = (menuTitle, userBrewSnippets, themeBundleSnippets)=>{
|
|||||||
if(userBrewSnippets) {
|
if(userBrewSnippets) {
|
||||||
const userSnippets = [];
|
const userSnippets = [];
|
||||||
for (let snips of userBrewSnippets.split(textSplit)) {
|
for (let snips of userBrewSnippets.split(textSplit)) {
|
||||||
let name = mp.split('\n')[0];
|
let name = snips.split('\n')[0];
|
||||||
if(name.length != 0) {
|
if(name.length != 0) {
|
||||||
userSnippets.push({
|
userSnippets.push({
|
||||||
name : name,
|
name : name.slice('\snippet '.length),
|
||||||
icon : '',
|
icon : '',
|
||||||
gen : snips.split('\n').slice(0),
|
gen : snips.slice(name.length + 1),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,16 +70,19 @@ const splitTextStyleAndMetadata = (brew)=>{
|
|||||||
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.text = brew.text.slice(index + 5);
|
brew.text = brew.text.slice(index + 5);
|
||||||
}
|
}
|
||||||
if(brew.text.startsWith('```css')) {
|
|
||||||
const index = brew.text.indexOf('```\n\n');
|
|
||||||
brew.style = brew.text.slice(7, index - 1);
|
|
||||||
brew.text = brew.text.slice(index + 5);
|
|
||||||
}
|
|
||||||
if(brew.text.startsWith('```snippets')) {
|
if(brew.text.startsWith('```snippets')) {
|
||||||
const index = brew.text.indexOf('```\n\n');
|
const index = brew.text.indexOf('```\n\n');
|
||||||
brew.snippets = brew.text.slice(11, index - 1);
|
brew.snippets = brew.text.slice(11, index - 1);
|
||||||
brew.text = brew.text.slice(index + 5);
|
brew.text = brew.text.slice(index + 5);
|
||||||
}
|
}
|
||||||
|
if(brew.text.startsWith('```css')) {
|
||||||
|
const index = brew.text.indexOf('```\n\n');
|
||||||
|
brew.style = brew.text.slice(7, index - 1);
|
||||||
|
brew.text = brew.text.slice(index + 5);
|
||||||
|
}
|
||||||
|
// if(!brew?.snippets) {
|
||||||
|
brew.snippets = `\\snippet Example\nI am an example user snippet\n`;
|
||||||
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
const printCurrentBrew = ()=>{
|
const printCurrentBrew = ()=>{
|
||||||
|
|||||||
Reference in New Issue
Block a user