From a371deb9d1ec8f64606303f1da18d4384acf5d90 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sun, 29 Mar 2020 12:06:31 +0000 Subject: [PATCH] ImportHandler: quick & dirty way of being more lax when matching This change is meant to ease using LibreOffice as converter. When LibreOffice converts a file, it adds some classes to the <title> tag. This is a quick & dirty way of matching the <title> and comment it out independently on the classes that are set on it. --- src/node/handler/ImportHandler.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/node/handler/ImportHandler.js b/src/node/handler/ImportHandler.js index 52ea7ccca..02ef92635 100644 --- a/src/node/handler/ImportHandler.js +++ b/src/node/handler/ImportHandler.js @@ -185,8 +185,15 @@ async function doImport(req, res, padId) if (!req.directDatabaseAccess) { text = await fsp_readFile(destFile, "utf8"); - // Title needs to be stripped out else it appends it to the pad.. - text = text.replace("<title>", "<!-- <title>"); + /* + * The <title> tag needs to be stripped out, otherwise it is appended to the + * pad. + * + * Moreover, when using LibreOffice to convert the file, some classes are + * added to the <title> tag. This is a quick & dirty way of matching the + * title and comment it out independently on the classes that are set on it. + */ + text = text.replace("<title", "<!-- <title"); text = text.replace("","-->"); // node on windows has a delay on releasing of the file lock.