import Modifiers from "./modifiers" ; import resolveFileToURL from "./helper/resolveFileToURL" ; import Api from "../api" ; import Plugins from "../plugins" ; import Promise from "../utils/promise" ; import defaultBlocks from "../constants/defaultBlocks" ; import fileToOutput from "./helper/fileToOutput" ; const CODEBLOCK = "code" ; return { Array < Modifier > } function getModifiers ( output , page ) { const book = output . getBook ( ) ; const plugins = output . getPlugins ( ) ; const glossary = book . getGlossary ( ) ; const file = page . getFile ( ) ; const entries = glossary . getEntries ( ) ; const glossaryFile = glossary . getFile ( ) ; const glossaryFilename = fileToOutput ( output , glossaryFile . getPath ( ) ) ; const currentFilePath = file . getPath ( ) ; const blocks = Plugins . listBlocks ( plugins ) ; const code = blocks . get ( CODEBLOCK ) || defaultBlocks . get ( CODEBLOCK ) ; const context = Api . encodeGlobal ( output ) ; return [ Modifiers . addHeadingId , Modifiers . annotateText . bind ( null , entries , glossaryFilename ) , Modifiers . resolveImages . bind ( null , currentFilePath ) , Modifiers . resolveLinks . bind ( null , currentFilePath , resolveFileToURL . bind ( null , output ) ) , Modifiers . highlightCode . bind ( null , ( lang , source ) => { return Promise ( code . applyBlock ( { body : source , kwargs : { language : lang , } , } , context ) ) . then ( ( result ) => { if ( result . html === false ) { return { text : result . body } ; } else { return { html : result . body } ; } } ) ; } ) , ] ; } export default getModifiers ;