UNPKG

@signatu/policy

Version:
68 lines 2.8 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); var common_lib_1 = require("@signatu/common-lib"); var policyContent_1 = require("./policyContent"); var text_1 = require("./text"); var Showdown = __importStar(require("showdown")); var MarkdownContent = /** @class */ (function (_super) { __extends(MarkdownContent, _super); function MarkdownContent(value, language) { var _this = _super.call(this, value, language) || this; _this.converter = new Showdown.Converter(); _this.type = policyContent_1.ContentType.MARKDOWN; return _this; } Object.defineProperty(MarkdownContent.prototype, "value", { get: function () { return this.converter.makeHtml(this.internalValue); }, enumerable: true, configurable: true }); /** Rudimentary cleanups for markdown errors. */ MarkdownContent.clean = function (markdown) { if (markdown === void 0) { markdown = ""; } /** Bullet list(s) must be surrounded by newlines */ if (markdown.match(/^[ ]*\*/)) { return "\n\n" + markdown + "\n\n"; } return markdown; }; MarkdownContent.fromJSON = function (json) { var md = new MarkdownContent(json.value, common_lib_1.Language.fromJSON(json.language)); md.ref = json.ref; return md; }; MarkdownContent.prototype.equals = function (other) { return this.type === other.type && this.language.equals(other.language) && this.value === other.value; }; MarkdownContent.prototype.toJSON = function () { var json = _super.prototype.toJSON.call(this); // We need to store this._value, and not the computed property json.value = this.internalValue; return json; }; return MarkdownContent; }(text_1.TextContent)); exports.MarkdownContent = MarkdownContent; //# sourceMappingURL=markdown.js.map