cleanup
This commit is contained in:
parent
ec90d4c676
commit
268749a35b
@ -16,7 +16,7 @@ window.activeState = {
|
||||
fileName: "",
|
||||
lastElement: "",
|
||||
serverFilesTs: "",
|
||||
lineBreak: 200,
|
||||
lineBreak: 100,
|
||||
templates: [],
|
||||
templateFieldTypes: [
|
||||
"simpleInput",
|
||||
|
||||
@ -128,8 +128,8 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) {
|
||||
}
|
||||
|
||||
let bHtml = b.replace(/(?:\r\n|\r|\n)/g, "<br>");
|
||||
bHtml = bHtml.replace(/!l /g, " • ");
|
||||
bHtml = bHtml.replace(/!ls /g, " ○ ");
|
||||
//bHtml = bHtml.replace(/!l /g, " • ");
|
||||
//bHtml = bHtml.replace(/!ls /g, " ○ ");
|
||||
bHtml = bHtml.replace(/ /g, " ");
|
||||
|
||||
bHtml =
|
||||
@ -320,9 +320,10 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) {
|
||||
}
|
||||
|
||||
function parseGlobalLineBreak(data) {
|
||||
//parse each line of input with parseLineBreak return condensed string with newlines
|
||||
let parsedData = '';
|
||||
for (let line of data.split('\n')) {
|
||||
let parsedLine = parseLineBreak(line);
|
||||
let parsedLine = parseLineBreak(line, 0, activeState.lineBreak);
|
||||
if (parsedData != '') {
|
||||
parsedData = parsedData + '\n' + parsedLine;
|
||||
} else {
|
||||
@ -332,34 +333,43 @@ function parseFormOnSubmit(returnJSON = false, parseOnly = false) {
|
||||
return parsedData
|
||||
}
|
||||
|
||||
function parseLineBreak(line, intendation = 0) {
|
||||
//very much in development no idea yet
|
||||
|
||||
function parseLineBreak(line, intendation = 0, lineBreak = activeState.lineBreak - 5) {
|
||||
//add 5 chars buffer to fix list intendation issue
|
||||
//each input field gets parsed line by line twice once for list inputs and a second time for each input
|
||||
let lines;
|
||||
|
||||
if (line.length > activeState.lineBreak) {
|
||||
if (line.length > lineBreak) {
|
||||
//create linebreak in between second to last word
|
||||
let correctedLineBreak;
|
||||
let newLineStart;
|
||||
let cLBt = activeState.lineBreak-(intendation*2)
|
||||
let cLBt = lineBreak-(intendation*2)
|
||||
//find last space before linebreak
|
||||
correctedLineBreak = line.substring(0, cLBt).lastIndexOf(" ");
|
||||
//and fix the next lines start
|
||||
newLineStart = correctedLineBreak+1;
|
||||
//add to parsed output
|
||||
lines = line.substring(0, correctedLineBreak);
|
||||
//delete first parsed output from inputstring
|
||||
line = line.substring(newLineStart);
|
||||
|
||||
while(line.length > activeState.lineBreak) {
|
||||
let intendationSpaces = '';
|
||||
if (intendation != 0) intendationSpaces = ' '.repeat(intendation+1);
|
||||
let cLBt = activeState.lineBreak-(intendation*2)
|
||||
let intendationSpaces = '';
|
||||
//check if an intendation is given if so convert it to correct spaces
|
||||
if (intendation != 0) intendationSpaces = ' '.repeat(intendation+1);
|
||||
|
||||
//start loop to parse rest of the string
|
||||
while(line.length > lineBreak) {
|
||||
let cLBt = lineBreak-(intendation*2)
|
||||
correctedLineBreak = line.substring(0, cLBt).lastIndexOf(" ");
|
||||
newLineStart = correctedLineBreak+1;
|
||||
//add to output with intendation if given
|
||||
lines += "\n" + intendationSpaces + line.substring(0, correctedLineBreak);
|
||||
//delete from input
|
||||
line = line.substring(newLineStart);
|
||||
break;
|
||||
}
|
||||
let intendationSpaces = '';
|
||||
if (intendation != 0) intendationSpaces = ' '.repeat(intendation+1);
|
||||
//process rest of the string with correct intendation
|
||||
lines += "\n" + intendationSpaces + line;
|
||||
} else {
|
||||
//if string is within lineBreak just forward input to output
|
||||
lines = line;
|
||||
}
|
||||
return lines;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user