(html)
| 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); |
nothing calls this directly
no test coverage detected
searching dependent graphs…