Mercurial Hosting > sceditor
changeset 41:7491026f7623
remove isSelfClosing
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 19 Aug 2022 19:27:03 -0600 |
parents | eaecca025287 |
children | 69654081643b |
files | src/formats/bbcode.js |
diffstat | 1 files changed, 10 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
diff -r eaecca025287 -r 7491026f7623 src/formats/bbcode.js --- a/src/formats/bbcode.js Fri Aug 19 18:45:17 2022 -0600 +++ b/src/formats/bbcode.js Fri Aug 19 19:27:03 2022 -0600 @@ -148,7 +148,7 @@ txtExec: ['[table][tr][td]', '[/td][/tr][/table]'] }, horizontalrule: { - txtExec: ['[hr]'] + txtExec: ['[hr][/hr]'] }, code: { txtExec: ['[code]', '[/code]'] @@ -529,9 +529,8 @@ hr: null }, allowsEmpty: true, - isSelfClosing: true, isInline: false, - format: '[hr]{0}', + format: '[hr][/hr]', html: '<hr />' }, // END_COMMAND @@ -1294,16 +1293,16 @@ addTag(token); bbcode = bbcodeHandlers[token.name]; - // If this tag is not self closing and it has a closing + // If this tag has a closing // tag then it is open and has children so add it to the // list of open tags. If has the closedBy property then // it is closed by other tags so include everything as // it's children until one of those tags is reached. - if (bbcode && !bbcode.isSelfClosing && + if (bbcode && (bbcode.closedBy || hasTag(token.name, TOKEN_CLOSE, toks))) { openTags.push(token); - } else if (!bbcode || !bbcode.isSelfClosing) { + } else { token.type = TOKEN_CONTENT; } break; @@ -1467,8 +1466,7 @@ // Handle the start and end new lines // e.g. [tag]\n and \n[/tag] - if (!onlyRemoveBreakAfter && parentBBCode && - parentBBCode.isSelfClosing !== true) { + if (!onlyRemoveBreakAfter && parentBBCode) { // First child of parent so must be opening line break // (breakStartBlock, breakStart) e.g. [tag]\n if (!left) { @@ -1701,8 +1699,7 @@ // are all removed this one doesn't think it's not empty. removeEmpty(token.children); - if (isTokenWhiteSpace(token.children) && bbcode && - !bbcode.isSelfClosing && !bbcode.allowsEmpty) { + if (isTokenWhiteSpace(token.children) && bbcode && !bbcode.allowsEmpty) { tokens.splice.apply(tokens, [i, 1].concat(token.children)); } } @@ -1849,7 +1846,7 @@ * @private */ function convertToBBCode(toks) { - var token, attr, bbcode, isBlock, isSelfClosing, quoteType, + var token, attr, bbcode, isBlock, quoteType, breakBefore, breakStart, breakEnd, breakAfter, ret = ''; @@ -1860,13 +1857,12 @@ // TODO: tidy this bbcode = bbcodeHandlers[token.name]; isBlock = !(!bbcode || bbcode.isInline !== false); - isSelfClosing = bbcode && bbcode.isSelfClosing; breakBefore = (isBlock && base.opts.breakBeforeBlock && bbcode.breakBefore !== false) || (bbcode && bbcode.breakBefore); - breakStart = (isBlock && !isSelfClosing && + breakStart = (isBlock && base.opts.breakStartBlock && bbcode.breakStart !== false) || (bbcode && bbcode.breakStart); @@ -1918,7 +1914,7 @@ } // add closing tag if not self closing - if (!isSelfClosing && !bbcode.excludeClosing) { + if (!bbcode.excludeClosing) { if (breakEnd) { ret += '\n'; } @@ -1929,12 +1925,6 @@ if (breakAfter) { ret += '\n'; } - - // preserve whatever was recognized as the - // closing tag if it is a self closing tag - if (token.closing && isSelfClosing) { - ret += token.closing.val; - } } else { ret += token.val; }