/**
 * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ import ansiRegex from '@casual-simulation/chalk/ansi-regex' ; import style from '@casual-simulation/chalk/ansi-styles' ; import type { NewPlugin } from '../pretty-format' ; export const alignedAnsiStyleSerializer = { serialize ( val ) { return val . replace ( ansiRegex ( ) , ( match ) => { switch ( match ) { case style . inverse . open : return '<i>' ; case style . inverse . close : return '</i>' ; case style . bold . open : return '<b>' ; case style . dim . open : return '<d>' ; case style . green . open : return '<g>' ; case style . red . open : return '<r>' ; case style . yellow . open : return '<y>' ; case style . bgYellow . open : return '<Y>' ; case style . bold . close : case style . dim . close : case style . green . close : case style . red . close : case style . yellow . close : case style . bgYellow . close : return '</>' ; default : return match ; } } ) ; } , test ( val ) { return typeof val === 'string' ; } , } ;