UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

39 lines (38 loc) 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.noformatMacro = void 0; var _commonMacro = require("./common-macro"); var _attrs = require("../utils/attrs"); var _title = require("../utils/title"); var noformatMacro = exports.noformatMacro = function noformatMacro(_ref) { var input = _ref.input, position = _ref.position, schema = _ref.schema, context = _ref.context; return (0, _commonMacro.commonMacro)(input.substring(position), schema, { keyword: 'noformat', paired: true, context: context, rawContentProcessor: rawContentProcessor }); }; var rawContentProcessor = function rawContentProcessor(rawAttrs, rawContent, length, schema, _context) { var output = []; var codeBlock = schema.nodes.codeBlock; var parsedAttrs = (0, _attrs.parseAttrs)(rawAttrs); // Ignored via go/ees005 // eslint-disable-next-line require-unicode-regexp var trimedContent = rawContent.replace(/^\s+|\s+$/g, ''); var textNode = trimedContent.length ? schema.text(trimedContent) : undefined; if (parsedAttrs.title) { output.push((0, _title.title)(parsedAttrs.title, schema)); } output.push(codeBlock.createChecked({}, textNode)); return { type: 'pmnode', nodes: output, length: length }; };