fixed indentions and wrong line breaks in pdf, remove every tab in html (fixes #3678)

This commit is contained in:
FinnStutzenstein 2018-03-24 08:08:21 +01:00
parent 209ea70d75
commit ad5c81a3db
2 changed files with 27 additions and 7 deletions

View File

@ -846,19 +846,37 @@ angular.module('OpenSlidesApp.core.pdf', [])
case "br": case "br":
var brParent = element.parentNode; var brParent = element.parentNode;
var brParentNodeName = brParent.nodeName; var brParentNodeName = brParent.nodeName;
//in case of inline-line-numbers and the os-line-break class ignore the break //in case of no or inline-line-numbers and the ignore os-line-breaks.
if (((lineNumberMode === 'inline' || lineNumberMode === 'none') && if ((lineNumberMode === 'inline' || lineNumberMode === 'none') &&
hasClass(element, 'os-line-break')) || hasClass(element, 'os-line-break')) {
(lineNumberMode === 'outside' &&
hasClass(element, 'os-line-break') &&
hasClass(brParent, 'os-split-before'))) {
break; break;
} else { } else {
currentParagraph = create("text"); currentParagraph = create("text");
if (lineNumberMode === "outside" && if (lineNumberMode === "outside" &&
brParentNodeName !== "LI" && brParentNodeName !== "LI" &&
element.parentNode.parentNode.nodeName !== "LI") { element.parentNode.parentNode.nodeName !== "LI") {
currentParagraph.margin = [20, 0, 0, 0]; if (brParentNodeName === 'INS' || brParentNodeName === 'DEL') {
var hasPrevSiblingALineNumber = function (element) {
// Iterare all nodes up to the top from element.
while (element) {
if (getLineNumber(element)) {
return true;
}
if (element.previousSibling) {
element = element.previousSibling;
} else {
element = element.parentNode;
}
}
return false;
};
if (hasPrevSiblingALineNumber(brParent)) {
currentParagraph.margin = [20, 0, 0, 0];
}
} else {
currentParagraph.margin = [20, 0, 0, 0];
}
} }
// Add a dummy line, if the next tag is a BR tag again. The line could // Add a dummy line, if the next tag is a BR tag again. The line could
// not be empty otherwise it will be removed and the empty line is not displayed // not be empty otherwise it will be removed and the empty line is not displayed

View File

@ -24,7 +24,9 @@ def validate_html(html: str) -> str:
""" """
This method takes a string and escapes all non-whitelisted html entries. This method takes a string and escapes all non-whitelisted html entries.
Every field of a model that is loaded trusted in the DOM should be validated. Every field of a model that is loaded trusted in the DOM should be validated.
During copy and paste from Word maybe some tabs are spread over the html. Remove them.
""" """
html = html.replace('\t', '')
return bleach.clean( return bleach.clean(
html, html,
tags=allowed_tags, tags=allowed_tags,