mirror of
https://github.com/10h30/wordpress-export-to-markdown.git
synced 2026-07-11 18:56:14 +09:00
Trim everything
This commit is contained in:
+5
-3
@@ -8,8 +8,10 @@ const translator = require('./translator');
|
||||
async function parseFilePromise(config) {
|
||||
const content = fs.readFileSync(config.input, 'utf8');
|
||||
|
||||
const processors = { tagNameProcessors: [xml2js.processors.stripPrefix] };
|
||||
const data = await xml2js.parseStringPromise(content, processors);
|
||||
const data = await xml2js.parseStringPromise(content, {
|
||||
trim: true,
|
||||
tagNameProcessors: [xml2js.processors.stripPrefix]
|
||||
});
|
||||
|
||||
let images = collectImages(data, config);
|
||||
let posts = collectPosts(data);
|
||||
@@ -106,7 +108,7 @@ function getPostSlug(post) {
|
||||
}
|
||||
|
||||
function getPostTitle(post) {
|
||||
return post.title[0].trim().replace(/"/g, '\\"');
|
||||
return post.title[0].replace(/"/g, '\\"');
|
||||
}
|
||||
|
||||
function getPostDate(post) {
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ function initTurndownService() {
|
||||
}
|
||||
|
||||
function getPostContent(post, turndownService, config) {
|
||||
let content = post.encoded[0].trim();
|
||||
let content = post.encoded[0];
|
||||
|
||||
// insert an empty div element between double line breaks
|
||||
// this nifty trick causes turndown to keep adjacent paragraphs separated
|
||||
|
||||
Reference in New Issue
Block a user