UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

44 lines (43 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseNewlineOnly = parseNewlineOnly; exports.parseWhitespaceAndNewLine = parseWhitespaceAndNewLine; exports.parseWhitespaceOnly = parseWhitespaceOnly; function parseWhitespaceAndNewLine(input) { var newlineLength = parseNewlineOnly(input); if (newlineLength) { return newlineLength; } var whitespaceLength = parseWhitespaceOnly(input); if (whitespaceLength) { return whitespaceLength; } // There is nether whitespace nor newline return 0; } function parseWhitespaceOnly(input) { var index = 0; var char = input.charAt(index); if (char === '\t' || char === ' ') { index++; } return index; } function parseNewlineOnly(input) { var index = 0; var char = input.charAt(index); if (char === '\r') { // CR (Unix) index++; if (input.charAt(index) === '\n') { // CRLF (Windows) index++; } } else if (char === '\n') { // LF (MacOS) index++; } return index; }