Skip to content

Commit

Permalink
Changed default XML parser
Browse files Browse the repository at this point in the history
  • Loading branch information
mithray committed Nov 18, 2022
1 parent 6d301df commit 1a60f9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,6 @@ export const load =

}


//let url = "0ad/mods/public/simulation/templates/mixins/"
//console.log(await load("./ignored",{formats: ["json"]}))
//console.log(await load(url,{formats:["xml"]}))
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "load-object",
"version": "1.8.3",
"version": "1.8.4",
"description": "Takes a path to a file locally or remotely and loads that file into a Javascript Object.",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -37,6 +37,7 @@
"@iarna/toml": "^3.0.0",
"@ipld/dag-cbor": "^7.0.3",
"axios": "^1.1.3",
"fast-xml-parser": "^4.0.11",
"js-yaml": "^4.1.0",
"json-cycle": "^1.3.0",
"marked": "^4.1.1",
Expand Down
6 changes: 5 additions & 1 deletion src/parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import { decode as cborDecode } from "@ipld/dag-cbor"
import shelljs from "shelljs"
import { pipe } from "ramda"
import { parse as parseHTML } from "parse5"
import { XMLParser } from "fast-xml-parser"
//import * as cheerio from "cheerio"

const parseXMLInstance = new XMLParser()
const parseXML = (str) => parseXMLInstance.parse(str)

const parseJSON = JSON.parse
//const parseHTML = (x) => cheerio.load(x)

Expand All @@ -21,7 +25,7 @@ const parsers =
, json: parseJSON
, toml: parseTOML
, html: parseHTML
, xml: parseHTML
, xml: parseXML
, md: pipe(String, marked.parse, parseHTML)
, cbor: cborDecode
, dhall: (string, parser) => {
Expand Down

0 comments on commit 1a60f9b

Please sign in to comment.