@@ -34,6 +34,20 @@ function processBlock(blk) {
3434 var assetPath = ASSET_PATH ;
3535 var filePath = assetPath + crypto . createHash ( 'sha1' ) . update ( code ) . digest ( 'hex' ) + '.' + format ;
3636
37+ if ( this . ctx && this . ctx . ctx && this . ctx . ctx . file && this . ctx . ctx . file . path ) {
38+ var includePath = path . resolve ( path . dirname ( this . ctx . ctx . file . path ) ) ;
39+ var cwdPath = require ( "process" ) . cwd ( ) ;
40+ if ( includePath == cwdPath ) {
41+ config . include = includePath + ':' + cwdPath ;
42+ } else {
43+ if ( require ( "process" ) . platform == 'win32' ) {
44+ config . include = includePath + ';' + cwdPath ;
45+ } else {
46+ config . include = includePath + ':' + cwdPath ;
47+ }
48+ }
49+ }
50+
3751 if ( fs . existsSync ( filePath ) ) {
3852 var result = "<img src=/" + filePath + ">" ;
3953 deferred . resolve ( result ) ;
@@ -98,14 +112,29 @@ module.exports = {
98112 // https://github.com/vowstar/gitbook-plugin-uml/issues/2
99113 // Use SVG format by default in website when user not give
100114 // any configuration to get better result.
101- if ( name == 'website' ) {
102- this . book . config . set ( 'pluginsConfig.uml' , {
103- format : 'svg'
104- } ) ;
115+ var config = book . config . get ( 'pluginsConfig.uml' , { } ) ;
116+
117+ if ( config && config . format ) {
118+ // Do nothing here, user have set config
105119 } else {
106- this . book . config . set ( 'pluginsConfig.uml' , {
107- format : 'png'
108- } ) ;
120+ if ( name == 'website' ) {
121+ this . book . config . set ( 'pluginsConfig.uml' , {
122+ format : 'svg'
123+ } ) ;
124+ } else {
125+ // Auto select svg or png
126+ if ( this . honkit ) {
127+ // honkit support svg better, so use svg
128+ this . book . config . set ( 'pluginsConfig.uml' , {
129+ format : 'svg'
130+ } ) ;
131+ } else {
132+ // gitbook pdf not support svg
133+ this . book . config . set ( 'pluginsConfig.uml' , {
134+ format : 'png'
135+ } ) ;
136+ }
137+ }
109138 }
110139 }
111140 var startNailgun = this . book . config . get ( 'pluginsConfig.uml.nailgun' , false ) ;
0 commit comments