Skip to content

Commit

Permalink
fix: escaped characters are parsed post-yaml (close #32)
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jan 17, 2022
1 parent c32bc0e commit f56f47f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export function getMod(arg0: number) {
return `${mod >= 0 ? "+" : "-"}${Math.abs(mod)}`;
}


type YamlTrait = [string, ...{ [key: string]: any }[]];
/** Parse Yaml-Defined Trait to Trait */
export function parseTrait(arg: YamlTrait): Trait {
Expand All @@ -36,7 +35,7 @@ export function parseTrait(arg: YamlTrait): Trait {
}

export function getParamsFromSource(source: string): Monster {
const params = parseYaml(source);
let params = parseYaml(source);

const traits: Trait[] = [];
const actions: Trait[] = [];
Expand Down Expand Up @@ -81,6 +80,9 @@ export function getParamsFromSource(source: string): Monster {
);
}

//replace escapes
params = JSON.parse(JSON.stringify(params).replace(/\\/g, ""));

return { ...params, traits, actions, reactions, legendary_actions };
}

Expand Down

0 comments on commit f56f47f

Please sign in to comment.