"use strict";
const repository = require("../repository");
const utils = require('../utils');
async function exportToOpml(branch, res) {
const note = await branch.getNote();
async function exportNoteInner(branchId) {
const branch = await repository.getBranch(branchId);
const note = await branch.getNote();
if (await note.hasLabel('excludeFromExport')) {
return;
}
const title = (branch.prefix ? (branch.prefix + ' - ') : '') + note.title;
const preparedTitle = prepareText(title);
const preparedContent = prepareText(await note.getContent());
res.write(`
]*>|
)/g, '\n')
.replace(/ /g, ' '); // nbsp isn't in XML standard (only HTML)
const stripped = utils.stripTags(newLines);
const escaped = escapeXmlAttribute(stripped);
return escaped.replace(/\n/g, '
');
}
function escapeXmlAttribute(text) {
return text.replace(/&/g, '&')
.replace(//g, '>')
.replace(/"/g, '"')
.replace(/'/g, ''');
}
module.exports = {
exportToOpml
};