import { Injectable } from '@angular/core' ; import hljs from 'highlight.js' ; /**
 * Relevant output from Highlight.js methods
 */ export type CodeHighlightResult = { value : string ; language ? : string ; } ; author Jim Toth <jim@meme.coach>
  @ Injectable ( ) export class CodeHighlightService { static moduleWrapperClass : string = 'm-code-highlight' ; param { string } lang param { string } code highlight ( lang , code ) { if ( this . getLanguages ( ) . indexOf ( lang ) < 0 ) { return this . highlightAuto ( code ) ; } else if ( hljs ) { return hljs . highlight ( lang , code , true ) ; } return { value : code } ; } param { string } code returns { CodeHighlightResult } highlightAuto ( code ) { if ( hljs ) { return hljs . highlightAuto ( code ) ; } return { value : code } ; } param { Element } codeNode highlightBlock ( codeNode ) { if ( hljs ) { hljs . highlightBlock ( codeNode ) ; } } returns { string [ ] } getLanguages ( ) { if ( hljs ) { return hljs . listLanguages ( ) ; } return [ ] ; } }