ImportHandler: quick & dirty way of being more lax when matching <title>

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.
pull/3851/head
John McLear 2020-03-29 12:06:31 +00:00 committed by muxator
parent babf67175c
commit a371deb9d1
1 changed files with 9 additions and 2 deletions

View File

@ -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("</title>","</title>-->");
// node on windows has a delay on releasing of the file lock.