Font
This commit is contained in:
@@ -1 +1 @@
|
||||
1.1.75
|
||||
1.1.76
|
||||
@@ -90,7 +90,7 @@
|
||||
|
||||
wrapper.querySelectorAll('script,style').forEach((node) => node.remove());
|
||||
|
||||
const inlineTags = new Set(['A', 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'BR', 'SUB', 'SUP', 'SPAN']);
|
||||
const inlineTags = new Set(['A', 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'BR', 'SUB', 'SUP', 'SPAN', 'FONT']);
|
||||
const blockTags = new Set([
|
||||
'DIV', 'P', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6',
|
||||
'UL', 'OL', 'LI', 'TABLE', 'TBODY', 'THEAD', 'TFOOT', 'TR', 'TD', 'TH',
|
||||
@@ -116,6 +116,36 @@
|
||||
const tag = el.tagName;
|
||||
const tagLower = tag.toLowerCase();
|
||||
if (inlineTags.has(tag)) {
|
||||
if (tagLower === 'font') {
|
||||
const face = el.getAttribute('face');
|
||||
const size = el.getAttribute('size');
|
||||
const color = el.getAttribute('color');
|
||||
const styles = [];
|
||||
if (face) styles.push(`font-family:${face}`);
|
||||
if (color) styles.push(`color:${color}`);
|
||||
if (size) {
|
||||
const sizeMap = {
|
||||
1: '10px',
|
||||
2: '12px',
|
||||
3: '14px',
|
||||
4: '16px',
|
||||
5: '18px',
|
||||
6: '24px',
|
||||
7: '32px',
|
||||
};
|
||||
const mapped = sizeMap[size] || sizeMap[parseInt(size, 10)] || null;
|
||||
if (mapped) styles.push(`font-size:${mapped}`);
|
||||
}
|
||||
if (styles.length) {
|
||||
const span = document.createElement('span');
|
||||
span.setAttribute('style', styles.join(';'));
|
||||
while (el.firstChild) span.appendChild(el.firstChild);
|
||||
el.replaceWith(span);
|
||||
} else {
|
||||
unwrap(el, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (tagLower === 'a' && !el.getAttribute('href')) {
|
||||
unwrap(el, false);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user