app/assets/javascripts/styleguide/prism-line-numbers.js
function (element) {
		var codeStyles = getStyles(element);
		var whiteSpace = codeStyles['white-space'];

		if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
			var codeElement = element.querySelector('code');
			var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
			var lineNumberSizer = element.querySelector('.line-numbers-sizer');
			var codeLines = element.textContent.split('\n');

			if (!lineNumberSizer) {
				lineNumberSizer = document.createElement('span');
				lineNumberSizer.className = 'line-numbers-sizer';

				codeElement.appendChild(lineNumberSizer);
			}

			lineNumberSizer.style.display = 'block';

			codeLines.forEach(function (line, lineNumber) {
				lineNumberSizer.textContent = line || '\n';
				var lineSize = lineNumberSizer.getBoundingClientRect().height;
				lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
			});

			lineNumberSizer.textContent = '';
			lineNumberSizer.style.display = 'none';
		}
	}
function (element) {
		var codeStyles = getStyles(element);
		var whiteSpace = codeStyles['white-space'];

		if (whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line') {
			var codeElement = element.querySelector('code');
			var lineNumbersWrapper = element.querySelector('.line-numbers-rows');
			var lineNumberSizer = element.querySelector('.line-numbers-sizer');
			var codeLines = element.textContent.split('\n');

			if (!lineNumberSizer) {
				lineNumberSizer = document.createElement('span');
				lineNumberSizer.className = 'line-numbers-sizer';

				codeElement.appendChild(lineNumberSizer);
			}

			lineNumberSizer.style.display = 'block';

			codeLines.forEach(function (line, lineNumber) {
				lineNumberSizer.textContent = line || '\n';
				var lineSize = lineNumberSizer.getBoundingClientRect().height;
				lineNumbersWrapper.children[lineNumber].style.height = lineSize + 'px';
			});

			lineNumberSizer.textContent = '';
			lineNumberSizer.style.display = 'none';
		}
	}
function ( element ) { var codeStyles = getStyles ( element ) ; var whiteSpace = codeStyles [ 'white-space' ] ; if ( whiteSpace === 'pre-wrap' || whiteSpace === 'pre-line' ) { var codeElement = element . querySelector ( 'code' ) ; var lineNumbersWrapper = element . querySelector ( '.line-numbers-rows' ) ; var lineNumberSizer = element . querySelector ( '.line-numbers-sizer' ) ; var codeLines = element . textContent . split ( '\n' ) ; if ( ! lineNumberSizer ) { lineNumberSizer = document . createElement ( 'span' ) ; lineNumberSizer . className = 'line-numbers-sizer' ; codeElement . appendChild ( lineNumberSizer ) ; } lineNumberSizer . style . display = 'block' ; codeLines . forEach ( function ( line , lineNumber ) { lineNumberSizer . textContent = line || '\n' ; var lineSize = lineNumberSizer . getBoundingClientRect ( ) . height ; lineNumbersWrapper . children [ lineNumber ] . style . height = lineSize + 'px' ; } ) ; lineNumberSizer . textContent = '' ; lineNumberSizer . style . display = 'none' ; } }
Resizes line numbers spans according to height of line of code
@param  {Element} element <pre> element
Resizes line numbers spans according to height of line of code