From ebeb96bab2ab86d0c43e5cfb56d8782aaf40c40e Mon Sep 17 00:00:00 2001 From: Ashley Wright Date: Mon, 4 Nov 2024 07:19:39 +0300 Subject: [PATCH 1/3] Add image support in descriptions --- odysseus/convertFtbQuests.ts | 45 ++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index ddf9e95..cd4f038 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -553,7 +553,7 @@ export const convertFtbQuests = async ( const fileWrites: Promise[] = []; const warnings = new Set(); - const formatString = (text: string) => { + const formatString = (text: string, description = false) => { let result = ""; for (let i = 0; i < text.length; ++i) { @@ -571,6 +571,47 @@ export const convertFtbQuests = async ( continue; } + if (description && character === "{") { + let end = text.indexOf("}", i + 1); + + const fieldsStrings = text.substring(i + 1, end).split(" "); + + const fields = fieldsStrings.map((field): [name: string, value: string] => { + const nameEnd = field.indexOf(":"); + + const name = field.substring(0, nameEnd); + const value = field.substring(nameEnd + 1); + + return [name, value]; + }); + + const obj = Object.fromEntries(fields); + + if ("image" in obj) { + text += ` formatString(s, true)) ?.map((s) => (s.length ? s : "
")) ?? []), ...(rewardsIds.length From 158fd456ad74fcee013ed8c4702816a5fc4a7863 Mon Sep 17 00:00:00 2001 From: Ashley Wright Date: Mon, 4 Nov 2024 07:24:56 +0300 Subject: [PATCH 2/3] Format & lint --- odysseus/convertFtbQuests.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index cd4f038..0d8649b 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -572,18 +572,20 @@ export const convertFtbQuests = async ( } if (description && character === "{") { - let end = text.indexOf("}", i + 1); + const end = text.indexOf("}", i + 1); const fieldsStrings = text.substring(i + 1, end).split(" "); - const fields = fieldsStrings.map((field): [name: string, value: string] => { - const nameEnd = field.indexOf(":"); + const fields = fieldsStrings.map( + (field): [name: string, value: string] => { + const nameEnd = field.indexOf(":"); - const name = field.substring(0, nameEnd); - const value = field.substring(nameEnd + 1); + const name = field.substring(0, nameEnd); + const value = field.substring(nameEnd + 1); - return [name, value]; - }); + return [name, value]; + }, + ); const obj = Object.fromEntries(fields); @@ -591,7 +593,11 @@ export const convertFtbQuests = async ( text += ` Date: Mon, 4 Nov 2024 07:25:47 +0300 Subject: [PATCH 3/3] It really doesn't like how I format this --- odysseus/convertFtbQuests.ts | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index d08070b..bd1c1a0 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -599,11 +599,9 @@ export const convertFtbQuests = async ( text += `