mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-11 18:56:14 +09:00
Remove global config variable
This commit is contained in:
+6
-14
@@ -5,28 +5,20 @@ const xml2js = require('xml2js');
|
||||
const shared = require('./shared');
|
||||
const translator = require('./translator');
|
||||
|
||||
let config;
|
||||
|
||||
async function parseFilePromise(configIn) {
|
||||
const content = fs.readFileSync(configIn.input, 'utf8');
|
||||
async function parseFilePromise(config) {
|
||||
const content = fs.readFileSync(config.input, 'utf8');
|
||||
|
||||
const processors = { tagNameProcessors: [xml2js.processors.stripPrefix] };
|
||||
const data = await xml2js.parseStringPromise(content, processors);
|
||||
|
||||
config = configIn;
|
||||
let images = collectImages(data, config);
|
||||
let posts = collectPosts(data);
|
||||
mergeImagesIntoPosts(images, posts);
|
||||
|
||||
let posts = processData(data);
|
||||
return Promise.resolve(posts);
|
||||
}
|
||||
|
||||
function processData(data) {
|
||||
let images = collectImages(data);
|
||||
let posts = collectPosts(data);
|
||||
mergeImagesIntoPosts(images, posts);
|
||||
return posts;
|
||||
}
|
||||
|
||||
function collectImages(data) {
|
||||
function collectImages(data, config) {
|
||||
// start by collecting all attachment images
|
||||
let images = getItemsOfType(data, 'attachment')
|
||||
// filter to certain image file types
|
||||
|
||||
Reference in New Issue
Block a user