Files
inpx-web/server/core/fb2/Fb2Parser.js
2022-11-10 00:51:18 +07:00

43 lines
1.0 KiB
JavaScript

const XmlParser = require('../xml/XmlParser');
class Fb2Parser extends XmlParser {
bookInfo(fb2Object) {
if (!fb2Object)
fb2Object = this.toObject();
//const result = {};
}
bookInfoList(fb2Object) {
}
toHtml(xmlString) {
const substs = {
'<subtitle>': '<p><b>',
'</subtitle>': '</b></p>',
'<empty-line/>': '<br>',
'<strong>': '<b>',
'</strong>': '</b>',
'<emphasis>': '<i>',
'</emphasis>': '</i>',
'<stanza>': '<br>',
'</stanza>': '',
'<poem>': '<br>',
'</poem>': '',
'<cite>': '<i>',
'</cite>': '</i>',
'<table>': '<br>',
'</table>': '',
};
for (const [tag, s] of Object.entries(substs)) {
const r = new RegExp(`${tag}`, 'g');
xmlString = xmlString.replace(r, s);
}
return xmlString;
}
}
module.exports = Fb2Parser;