MCPcopy Create free account
hub / github.com/UI5/webcomponents / format

Function format

packages/main/test/pages/diffable-html.js:1996–2229  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

1994 'wbr' ];
1995
1996 var format = function(html) {
1997 var elements = [];
1998 var indentSize = 2;
1999
2000 var currentDepth = 0;
2001
2002 var increaseCurrentDepth = function () {
2003 currentDepth++;
2004 };
2005
2006 var decreaseCurrentDepth = function () {
2007 currentDepth--;
2008 };
2009
2010 var getIndentation = function (size) {
2011 return ' '.repeat(size);
2012 };
2013
2014 var getIndentationForDepth = function (depth) {
2015 return getIndentation(indentSize * depth);
2016 };
2017
2018 var getCurrentIndentation = function () {
2019 return getIndentationForDepth(currentDepth);
2020 };
2021
2022 var getAttributeIndentation = function (tagName) {
2023 return getIndentation(indentSize * currentDepth + tagName.length - 1);
2024 };
2025
2026 var getAttributeIndentationForCurrentTag = function () {
2027 return getAttributeIndentation(currentTag);
2028 };
2029
2030 var append = function (content) {
2031 elements.push(content);
2032 };
2033
2034 var appendLineBreak = function () {
2035 append('\n');
2036 };
2037
2038 var appendIndentation = function (depth) {
2039 append(getIndentationForDepth(depth));
2040 };
2041
2042 var appendCurrentIndentation = function () {
2043 append(getCurrentIndentation());
2044 };
2045
2046 var appendOpeningTag = function (name) {
2047 append('<' + name);
2048 };
2049
2050 var appendClosingTagOnSameLine = function (closeWith) {
2051 if ( closeWith === void 0 ) closeWith = '>';
2052
2053 append(closeWith);

Callers

nothing calls this directly

Calls 13

isXmlDirectiveFunction · 0.85
appendLineBreakFunction · 0.85
appendCurrentIndentationFunction · 0.85
increaseCurrentDepthFunction · 0.85
appendOpeningTagFunction · 0.85
appendAttributesFunction · 0.85
appendClosingTagFunction · 0.85
decreaseCurrentDepthFunction · 0.85
isVoidTagNameFunction · 0.85
endMethod · 0.80
appendFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…