mirror of
https://github.com/Kvan7/Exiled-Exchange-2.git
synced 2026-09-26 14:45:44 +00:00
parser: poe markup in name lines
This commit is contained in:
+17
-2
@@ -189,8 +189,8 @@ function parseNamePlate (section: string[]) {
|
||||
|
||||
const item: ParsedItem = {
|
||||
rarity,
|
||||
name: section[1].replace(/^(<<.*?>>|<.*?>)+/, ''), // Item from chat "<<set:MS>><<set:M>><<set:S>>Beast Grinder"
|
||||
baseType: section[2]?.replace(/^(<<.*?>>|<.*?>)+/, ''),
|
||||
name: markupConditionParser(section[1]),
|
||||
baseType: (section.length >= 3) ? markupConditionParser(section[2]) : undefined,
|
||||
props: {},
|
||||
isUnidentified: false,
|
||||
isCorrupted: false,
|
||||
@@ -651,3 +651,18 @@ function parseHeistMission (section: string[], item: ParsedItem) {
|
||||
|
||||
return SECTION_PARSED
|
||||
}
|
||||
|
||||
function markupConditionParser (text: string) {
|
||||
// ignores state set by <<set:__>>
|
||||
// always evaluates first condition to true <if:__>{...}
|
||||
// full markup: https://gist.github.com/SnosMe/151549b532df8ea08025a76ae2920ca4
|
||||
|
||||
text = text.replace(/<<set:.+?>>/g, '')
|
||||
text = text.replace(/<(if:.+?|elif:.+?|else)>{(.+?)}/g, (_, type: string, body: string) => {
|
||||
return type.startsWith('if:')
|
||||
? body
|
||||
: ''
|
||||
})
|
||||
|
||||
return text
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user