mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-05 21:02:43 +00:00
Working, but ugly
This commit is contained in:
@@ -301,6 +301,7 @@ const blockDefinitionLists = {
|
|||||||
let inList = false;
|
let inList = false;
|
||||||
let lastEmpty = false;
|
let lastEmpty = false;
|
||||||
let inlineDefinitions = false;
|
let inlineDefinitions = false;
|
||||||
|
let appending = false;
|
||||||
while (match = regex.exec(src)) {
|
while (match = regex.exec(src)) {
|
||||||
// If we aren't actively in a DL and we match just text, bail.
|
// If we aren't actively in a DL and we match just text, bail.
|
||||||
// If the last loop bailed with lastEmpty and we match just text, bail
|
// If the last loop bailed with lastEmpty and we match just text, bail
|
||||||
@@ -308,9 +309,17 @@ const blockDefinitionLists = {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
endIndex += match[0].length;
|
endIndex += match[0].length;
|
||||||
|
|
||||||
// Check to see if this a match containing the start of a DD.
|
// Check to see if this a match containing the start of a DD.
|
||||||
if(match[0].indexOf('::') > -1) {
|
if(match[0].indexOf('::') > -1) {
|
||||||
inList = true;
|
inList = true;
|
||||||
|
// Check and see if we are currently in line appending mode
|
||||||
|
if(appending) {
|
||||||
|
const lastPos = typeof currentDefinition.dd.length !== 'undefined' ? currentDefinition.dd.length - 1 : 0;
|
||||||
|
currentDefinition.dd[lastPos] = `${currentDefinition.dd[lastPos]} ${match[1]?.trim()}`;
|
||||||
|
match[1] = '';
|
||||||
|
}
|
||||||
|
appending = false;
|
||||||
// Check for a DT value.
|
// Check for a DT value.
|
||||||
if(match[1]?.trim()?.length>0) {
|
if(match[1]?.trim()?.length>0) {
|
||||||
if(currentDefinition?.dt?.length) {
|
if(currentDefinition?.dt?.length) {
|
||||||
@@ -341,7 +350,7 @@ const blockDefinitionLists = {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Multi-line style DDs
|
// Multi-line style DDs
|
||||||
const newDefinitions = _.flatten(match[2].split('::').filter((item)=>item).map((s)=>s.trim()));
|
const newDefinitions = _.flatten(match[2].split('\n::').filter((item)=>item).map((s)=>s.trim()));
|
||||||
if(newDefinitions?.length) {
|
if(newDefinitions?.length) {
|
||||||
currentDefinition.dd = currentDefinition.dd.concat(newDefinitions);
|
currentDefinition.dd = currentDefinition.dd.concat(newDefinitions);
|
||||||
}
|
}
|
||||||
@@ -364,6 +373,7 @@ const blockDefinitionLists = {
|
|||||||
lastEmpty = false;
|
lastEmpty = false;
|
||||||
const lastPos = typeof currentDefinition.dd.length !== 'undefined' ? currentDefinition.dd.length - 1 : 0;
|
const lastPos = typeof currentDefinition.dd.length !== 'undefined' ? currentDefinition.dd.length - 1 : 0;
|
||||||
currentDefinition.dd[lastPos] = `${currentDefinition.dd[lastPos]} ${match[0].trim()}`;
|
currentDefinition.dd[lastPos] = `${currentDefinition.dd[lastPos]} ${match[0].trim()}`;
|
||||||
|
appending = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user