@@ -29,13 +29,15 @@ const include_plugin = (md, options) => {
2929 } ;
3030 }
3131
32- const _replaceIncludeByContent = ( src , rootdir , parentFilePath , filesProcessed ) => {
32+ const _replaceIncludeByContent = ( src , rootdir , state , parentFilePath , filesProcessed ) => {
3333 filesProcessed = filesProcessed ? filesProcessed . slice ( ) : [ ] ; // making a copy
3434 let cap , filePath , mdSrc , errorMessage , regionName ;
3535
3636 // store parent file path to check circular references
3737 if ( parentFilePath ) {
3838 filesProcessed . push ( parentFilePath ) ;
39+ // fixed 嵌套引用记录
40+ state . env . parentRootFilePaths = filesProcessed ;
3941 }
4042 while ( ( cap = options . includeRe . exec ( src ) ) ) {
4143 let includePath = cap [ 1 ] . trim ( ) ;
@@ -81,7 +83,7 @@ const include_plugin = (md, options) => {
8183 // get content of child file
8284 mdSrc = fs . readFileSync ( filePath , 'utf8' ) ;
8385 // check if child file also has includes
84- mdSrc = _replaceIncludeByContent ( mdSrc , path . dirname ( filePath ) , filePath , filesProcessed ) ;
86+ mdSrc = _replaceIncludeByContent ( mdSrc , path . dirname ( filePath ) , state , filePath , filesProcessed ) ;
8587
8688 if ( regionName ) {
8789 const lines = mdSrc . split ( / \r ? \n / )
@@ -117,7 +119,7 @@ const include_plugin = (md, options) => {
117119
118120 const _includeFileParts = ( state , startLine , endLine /*, silent*/ ) => {
119121 const root = options . getRootDir ( options , state , startLine , endLine ) ;
120- state . src = _replaceIncludeByContent ( state . src , root ) ;
122+ state . src = _replaceIncludeByContent ( state . src , root , state ) ;
121123 } ;
122124
123125 md . core . ruler . before ( 'normalize' , 'include' , _includeFileParts ) ;
0 commit comments