'use strict' ; import { vscMockArrays } from './arrays' ; export namespace vscMockHtmlContent { export interface IMarkdownString { value : string ; isTrusted ? : boolean ; } export class MarkdownString implements IMarkdownString { value : string ; isTrusted ? : boolean ; constructor ( value = '' ) { this . value = value ; } appendText ( value ) { this . value += value . replace ( /[\\`*_{}[\]()#+\-.!]/g , '\\$&' ) ; return this ; } appendMarkdown ( value ) { this . value += value ; return this ; } appendCodeblock ( langId , code ) { this . value += '\n```' ; this . value += langId ; this . value += '\n' ; this . value += code ; this . value += '\n```\n' ; return this ; } } export function isEmptyMarkdownString ( oneOrMany ) { if ( isMarkdownString ( oneOrMany ) ) { return ! oneOrMany . value ; } else if ( Array . isArray ( oneOrMany ) ) { return oneOrMany . every ( isEmptyMarkdownString ) ; } else { return true ; } } export function isMarkdownString ( thing ) { if ( thing instanceof MarkdownString ) { return true ; } else if ( thing && typeof thing === 'object' ) { return ( typeof ( < IMarkdownString > thing ) . value === 'string' && ( typeof ( < IMarkdownString > thing ) . isTrusted === 'boolean' || ( < IMarkdownString > thing ) . isTrusted === void 0 ) ) ; } return false ; } export function markedStringsEquals ( a , b ) { if ( ! a && ! b ) { return true ; } else if ( ! a || ! b ) { return false ; } else if ( Array . isArray ( a ) && Array . isArray ( b ) ) { return vscMockArrays . equals ( a , b , markdownStringEqual ) ; } else if ( isMarkdownString ( a ) && isMarkdownString ( b ) ) { return markdownStringEqual ( a , b ) ; } else { return false ; } } function markdownStringEqual ( a , b ) { if ( a === b ) { return true ; } else if ( ! a || ! b ) { return false ; } else { return a . value === b . value && a . isTrusted === b . isTrusted ; } } export function removeMarkdownEscapes ( text ) { if ( ! text ) { return text ; } return text . replace ( /\\([\\`*_{}[\]()#+\-.!])/g , '$1' ) ; } }