@@ -8,7 +8,6 @@ import { DOMParser as dom } from "xmldom";
88const readdir = util . promisify ( fs . readdir ) ;
99const open = util . promisify ( fs . open ) ;
1010const readFile = util . promisify ( fs . readFile ) ;
11- const errors = [ ] ;
1211
1312// latex (pdf version)
1413import {
@@ -158,35 +157,31 @@ async function translateXml(filepath, filename, option) {
158157 }
159158
160159 if ( parseType == "json" ) {
161- try {
162- const relativeFilePath = path . join (
163- filepath ,
164- filename . replace ( / \. x m l $ / , "" ) + ".html"
165- ) ;
160+ const relativeFilePath = path . join (
161+ filepath ,
162+ filename . replace ( / \. x m l $ / , "" ) + ".html"
163+ ) ;
166164
167- if ( option == "generateTOC" ) {
168- generateTOC ( doc , tableOfContent , relativeFilePath ) ;
169- return ;
170- } else if ( option == "setupSnippet" ) {
171- setupSnippetsJson ( doc . documentElement ) ;
172- setupReferencesJson ( doc . documentElement , relativeFilePath ) ;
173- return ;
174- } else if ( option == "parseXml" ) {
175- const jsonObj = [ ] ;
176- parseXmlJson ( doc , jsonObj , relativeFilePath ) ;
177-
178- const outputFile = path . join (
179- outputDir ,
180- tableOfContent [ relativeFilePath ] . index + ".json"
181- ) ;
182- const stream = fs . createWriteStream ( outputFile ) ;
183- stream . once ( "open" , fd => {
184- stream . write ( JSON . stringify ( jsonObj ) ) ;
185- stream . end ( ) ;
186- } ) ;
187- }
188- } catch ( error ) {
189- errors . push ( path . join ( filepath , filename ) + " " + error ) ;
165+ if ( option == "generateTOC" ) {
166+ generateTOC ( doc , tableOfContent , relativeFilePath ) ;
167+ return ;
168+ } else if ( option == "setupSnippet" ) {
169+ setupSnippetsJson ( doc . documentElement ) ;
170+ setupReferencesJson ( doc . documentElement , relativeFilePath ) ;
171+ return ;
172+ } else if ( option == "parseXml" ) {
173+ const jsonObj = [ ] ;
174+ parseXmlJson ( doc , jsonObj , relativeFilePath ) ;
175+
176+ const outputFile = path . join (
177+ outputDir ,
178+ tableOfContent [ relativeFilePath ] . index + ".json"
179+ ) ;
180+ const stream = fs . createWriteStream ( outputFile ) ;
181+ stream . once ( "open" , fd => {
182+ stream . write ( JSON . stringify ( jsonObj ) ) ;
183+ stream . end ( ) ;
184+ } ) ;
190185 }
191186 return ;
192187 }
0 commit comments