import remark from 'remark' ; import gfm from 'remark-gfm' ; import { compiler } from './libs/compiler' ; export default ( input ) : Promise < string > => { let mdText = input ; if ( typeof input === 'object' ) { if ( input instanceof Buffer ) { mdText = input . toString ( ) ; } else if ( typeof input !== 'string' ) { throw new Error ( 'It allows string or buffer' ) ; } } return new Promise < string > ( ( resolve , ng ) => { remark ( ) . use ( gfm ) . use ( compiler ) . process ( mdText , ( err , file ) => { if ( err ) return ng ( err ) ; const result = ( file + '' ) as string ; return resolve ( result ) ; } ) ; } ) ; } ;