forked from LokeshN/ep_foot_note
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexportHTML.js
37 lines (31 loc) · 1.12 KB
/
exportHTML.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict';
const ChangeSet = require('ep_etherpad-lite/static/js/Changeset');
exports.exportHtmlAdditionalTags = (hook, pad, cb) => cb(['fn', 'fnss', 'sup']);
const checkFootNoteInLine = (lineAttrib, pool) => {
let fn = null;
if (lineAttrib) {
const iter = ChangeSet.opIterator(lineAttrib);
if (iter.hasNext()) {
const op = iter.next();
fn = ChangeSet.opAttributeValue(op, 'fnEndLine', pool);
}
}
return fn;
};
exports.getLineHTMLForExport = async (hook, context) => {
const fn = checkFootNoteInLine(context.attribLine, context.apool);
context.lineContent = context.lineContent.replace(/<fnss/g, '<sup');
context.lineContent = context.lineContent.replace(/<\/fnss/g, '</sup');
if (context.text.indexOf('*') === 0) {
context.lineContent = context.lineContent.replace('*', '');
}
let text = context.text;
if (context.text.indexOf('*') === 0) {
text = context.text.replace('*', '');
}
if (fn) {
const replacedText = context.lineContent.replace(context.text, text);
context.lineContent = `<span class="fnEndLine">${replacedText}</span>`;
}
return context.lineContent;
};