Skip to content

Commit

Permalink
fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mikaylahubbard committed Jul 23, 2024
1 parent b87c939 commit 82f1164
Showing 1 changed file with 36 additions and 38 deletions.
74 changes: 36 additions & 38 deletions convert/convertConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export type ConfigData = {
width: number;
height: number;
file: string;
}
};
}[];
};

Expand Down Expand Up @@ -302,11 +302,11 @@ function parseStyles(stylesTag: Element, verbose: number) {
if (verbose)
console.log(
'Parsing ' +
propName +
' = ' +
propValue +
' -> ' +
properties[propName]
propName +
' = ' +
propValue +
' -> ' +
properties[propName]
);
} else {
//Not a sp value
Expand Down Expand Up @@ -619,8 +619,8 @@ function convertConfig(dataDir: string, verbose: number) {
const fontChoiceTag = book.querySelector('font-choice');
const fonts = fontChoiceTag
? Array.from(fontChoiceTag.getElementsByTagName('font-choice-family'))
.filter((x) => fontFamilies.includes(x.innerHTML))
.map((x) => x.innerHTML)
.filter((x) => fontFamilies.includes(x.innerHTML))
.map((x) => x.innerHTML)
: [];
const bkAdditionalNames = book.querySelector('additional-names');
const additionalNames = bkAdditionalNames
Expand Down Expand Up @@ -668,8 +668,8 @@ function convertConfig(dataDir: string, verbose: number) {
if (verbose >= 3) console.log(`.... fontChoice: `, JSON.stringify(fontChoiceTag));
const fonts = fontChoiceTag
? Array.from(fontChoiceTag.getElementsByTagName('font-choice-family'))
.filter((x) => fontFamilies.includes(x.innerHTML))
.map((x) => x.innerHTML)
.filter((x) => fontFamilies.includes(x.innerHTML))
.map((x) => x.innerHTML)
: [];

const writingSystem = tag.getElementsByTagName('writing-system')[0];
Expand Down Expand Up @@ -770,7 +770,8 @@ function convertConfig(dataDir: string, verbose: number) {
}
if (verbose)
console.log(
`Converted ${Object.keys(data.translationMappings.mappings).length
`Converted ${
Object.keys(data.translationMappings.mappings).length
} translation mappings`
);
}
Expand Down Expand Up @@ -843,12 +844,12 @@ function convertConfig(dataDir: string, verbose: number) {
placementTag == undefined
? undefined
: {
pos: placementTag.attributes.getNamedItem('pos')!.value,
ref: placementTag.attributes.getNamedItem('ref')!.value.split('|')[1],
collection: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[0]
};
pos: placementTag.attributes.getNamedItem('pos')!.value,
ref: placementTag.attributes.getNamedItem('ref')!.value.split('|')[1],
collection: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[0]
};
const tagWidth = tag.attributes.getNamedItem('width')
? parseInt(tag.attributes.getNamedItem('width')!.value)
: 0;
Expand Down Expand Up @@ -904,17 +905,17 @@ function convertConfig(dataDir: string, verbose: number) {
placementTag == undefined
? undefined
: {
pos: placementTag.attributes.getNamedItem('pos')!.value,
ref: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[1],
caption: placementTag.attributes.getNamedItem('caption')
? placementTag.attributes.getNamedItem('caption')!.value
: '',
collection: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[0]
};
pos: placementTag.attributes.getNamedItem('pos')!.value,
ref: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[1],
caption: placementTag.attributes.getNamedItem('caption')
? placementTag.attributes.getNamedItem('caption')!.value
: '',
collection: placementTag.attributes
.getNamedItem('ref')!
.value.split('|')[0]
};
data.illustrations.push({
filename: filename,
width: imageWidth,
Expand Down Expand Up @@ -951,8 +952,8 @@ function convertConfig(dataDir: string, verbose: number) {
const layoutCollections =
layoutCollectionElements.length > 0
? Array.from(layoutCollectionElements).map((element) => {
return element.attributes.getNamedItem('id')!.value;
})
return element.attributes.getNamedItem('id')!.value;
})
: [data.bookCollections[0].id];

data.layouts.push({
Expand Down Expand Up @@ -1055,8 +1056,7 @@ function convertConfig(dataDir: string, verbose: number) {
}

//plans
const plansTags = document
.getElementsByTagName('plans');
const plansTags = document.getElementsByTagName('plans');
if (plansTags?.length > 0) {
const plansTag = plansTags[0];
const featuresTag = plansTag.getElementsByTagName('features')[0];
Expand All @@ -1081,32 +1081,30 @@ function convertConfig(dataDir: string, verbose: number) {
title[titleTag.attributes.getNamedItem('lang')!.value] = titleTag.innerHTML;
}
//image
const imageTag = tag
.getElementsByTagName('image')[0];
const imageTag = tag.getElementsByTagName('image')[0];

let image = undefined;
if (imageTag.innerHTML) {
image = {
width: Number(imageTag.attributes.getNamedItem('width')!.value),
height: Number(imageTag.attributes.getNamedItem('height')!.value),
file: imageTag.innerHTML
}
};
}


const plan = {
id: tag.attributes.getNamedItem('id')!.value,
days: Number(tag.attributes.getNamedItem('days')!.value),
title,
filename: tag.getElementsByTagName('filename')[0].innerHTML,
image
}
};
plans.push(plan);
}
data.plans = {
features,
plans
}
};
}
}

Expand Down

0 comments on commit 82f1164

Please sign in to comment.