Merge pull request #3679 from FinnStutzenstein/fixes

fixed indentions in pdf, remove every tab in html (fixes #3678)
This commit is contained in:
Emanuel Schütze 2018-04-04 11:39:48 +02:00 committed by GitHub
commit 147fa6f370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 7 deletions

View File

@ -847,19 +847,37 @@ angular.module('OpenSlidesApp.core.pdf', [])
case "br":
var brParent = element.parentNode;
var brParentNodeName = brParent.nodeName;
//in case of inline-line-numbers and the os-line-break class ignore the break
if (((lineNumberMode === 'inline' || lineNumberMode === 'none') &&
hasClass(element, 'os-line-break')) ||
(lineNumberMode === 'outside' &&
hasClass(element, 'os-line-break') &&
hasClass(brParent, 'os-split-before'))) {
//in case of no or inline-line-numbers and the ignore os-line-breaks.
if ((lineNumberMode === 'inline' || lineNumberMode === 'none') &&
hasClass(element, 'os-line-break')) {
break;
} else {
currentParagraph = create("text");
if (lineNumberMode === "outside" &&
brParentNodeName !== "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
// 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.
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(
html,
tags=allowed_tags,