Skip to content

Commit

Permalink
fix: topsheet doesn't parse XML correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
billyc committed Mar 10, 2022
1 parent b553082 commit 107c277
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/components/TopSheet/TopSheetWorker.worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import YAML from 'yaml'
import { FileSystemConfig, YamlConfigs } from '@/Globals'
import HTTPFileSystem from '@/js/HTTPFileSystem'
import { findMatchingGlobInFiles, parseXML } from '@/js/util'
import globalStore from '@/store'

type TableRow = {
title: string
Expand Down Expand Up @@ -377,7 +376,8 @@ async function parseVariousFileTypes(fileKey: string, filename: string, text: st
const xml = (await parseXML(text, {
mergeAttrs: true,
explicitArray: false,
attrValueProcessors: [parseNumbers],
parseAttributeValue: true,
attributeNamePrefix: '',
})) as any

// Do a splitty lookup if the xmlElement is specified
Expand Down
5 changes: 4 additions & 1 deletion src/js/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ export async function parseXML(xml: string, settings: any = {}) {
}

// Allow user to pass in an array of "always as array" XML paths:
if (settings.alwaysArray)
if (settings.alwaysArray) {
defaultConfig.isArray = (name: string, jpath: string) => {
if (settings.alwaysArray.indexOf(jpath) !== -1) return true
}
} else {
delete defaultConfig.isArray
}

const options = Object.assign(defaultConfig, settings)
const parser = new XMLParser(options)
Expand Down

0 comments on commit 107c277

Please sign in to comment.