This commit is contained in:
TheGiddyLimit
2024-03-26 22:43:48 +00:00
parent 12f34a38f8
commit d075252329
122 changed files with 4907 additions and 1489 deletions

View File

@@ -89,6 +89,7 @@ class CreatureParser extends BaseParser {
if (!nxtLine) return false;
if (ConvertUtil.isNameLine(nxtLine)) return false; // avoid absorbing the start of traits
if (ConvertUtil.isListItemLine(nxtLine)) return false;
if (this._NO_ABSORB_TITLES.some(it => nxtLine.toUpperCase().includes(it))) return false;
if (this._NO_ABSORB_SUBTITLES.some(it => nxtLine.toUpperCase().startsWith(it))) return false;
@@ -745,7 +746,7 @@ class CreatureParser extends BaseParser {
for (let i = 0; i < block.entries.length; ++i) {
const curLine = block.entries[i];
if (typeof curLine !== "string" || !curLine.trim().endsWith(":")) continue;
if (typeof curLine !== "string") continue;
let lst = null;
let offset = 1;
@@ -756,13 +757,14 @@ class CreatureParser extends BaseParser {
if (typeof nxtLine !== "string" || !/^[•●]/.test(nxtLine.trim())) break;
nxtLine = nxtLine.replace(/^[•●]\s*/, "");
const listItem = this._doMergeBulletedLists_getListItem(nxtLine);
if (!lst) {
lst = {type: "list", items: [nxtLine]};
lst = {type: "list", items: [listItem]};
block.entries[i + offset] = lst;
offset++;
} else {
lst.items.push(nxtLine);
lst.items.push(listItem);
block.entries.splice(i + offset, 1);
}
}
@@ -770,6 +772,17 @@ class CreatureParser extends BaseParser {
});
}
static _doMergeBulletedLists_getListItem (str) {
if (!ConvertUtil.isNameLine(str)) return str;
const {name, entry} = ConvertUtil.splitNameLine(str);
return {
type: "item",
name,
entry,
};
}
static _mutAssignPrettyType ({obj, type}) {
const tmp = {...obj};
Object.keys(obj).forEach(k => delete obj[k]);