UNPKG

@atlaskit/editor-wikimarkup-transformer

Version:

Wiki markup transformer for JIRA and Confluence

33 lines 1.12 kB
import { commonMacro } from './common-macro'; import { parseAttrs } from '../utils/attrs'; import { title } from '../utils/title'; export var noformatMacro = function noformatMacro(_ref) { var input = _ref.input, position = _ref.position, schema = _ref.schema, context = _ref.context; return 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 = 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(title(parsedAttrs.title, schema)); } output.push(codeBlock.createChecked({}, textNode)); return { type: 'pmnode', nodes: output, length: length }; };