@@ -16,10 +16,8 @@ import {
1616} from "../lib/mapped-text.ts" ;
1717
1818import { dirname , join , normalize , relative } from "path/mod.ts" ;
19- import { encodeMetadata } from "../encode-metadata.ts" ;
2019import { rangedLines } from "../lib/ranged-text.ts" ;
2120import {
22- getShortcodeNamedParams ,
2321 getShortcodeUnnamedParams ,
2422 isBlockShortcode ,
2523} from "../lib/parse-shortcode.ts" ;
@@ -41,36 +39,10 @@ const includeHandler: LanguageHandler = {
4139 const sourceDir = dirname ( source ) ;
4240 const retrievedFiles : string [ ] = [ source ] ;
4341 const retrievedDirectories : string [ ] = [ sourceDir ] ;
44- const fixups : ( boolean | undefined ) [ ] = [ ] ;
4542
4643 const textFragments : EitherString [ ] = [ ] ;
4744
48- const needsFixup = ( ) => {
49- for ( let i = fixups . length - 1 ; i >= 0 ; -- i ) {
50- if ( fixups [ i ] !== undefined ) {
51- return fixups [ i ] ;
52- }
53- }
54- return true ;
55- } ;
56-
57- const addFixup = ( filename : string ) => {
58- if ( fixups . length > 0 && needsFixup ( ) ) {
59- let includeDir = relative ( sourceDir , dirname ( filename ) ) ;
60- if ( includeDir === "" ) {
61- includeDir = "." ;
62- }
63- textFragments . push ( encodeMetadata ( {
64- include_directory : includeDir ,
65- } ) ) ;
66- } else {
67- textFragments . push ( encodeMetadata ( {
68- clear_include_directory : true ,
69- } ) ) ;
70- }
71- } ;
72-
73- const retrieveInclude = ( filename : string , fixup : boolean | undefined ) => {
45+ const retrieveInclude = ( filename : string ) => {
7446 const norm = relative (
7547 join ( ...retrievedDirectories ) ,
7648 normalize ( filename ) ,
@@ -96,8 +68,6 @@ const includeHandler: LanguageHandler = {
9668
9769 retrievedFiles . push ( filename ) ;
9870 retrievedDirectories . push ( dirname ( norm ) ) ;
99- fixups . push ( fixup ) ;
100- addFixup ( filename ) ;
10171
10272 let rangeStart = 0 ;
10373 for ( const { substring, range } of rangedLines ( includeSrc . value ) ) {
@@ -108,18 +78,13 @@ const includeHandler: LanguageHandler = {
10878 ) ;
10979 rangeStart = range . end ;
11080 const params = getShortcodeUnnamedParams ( m ) ;
111- const options = getShortcodeNamedParams ( m ) ;
11281 if ( params . length === 0 ) {
11382 throw new Error ( "Include directive needs file parameter" ) ;
11483 }
11584 const file = params [ 0 ] ;
116- const fixup = options . fixup === undefined
117- ? undefined
118- : ( options . fixup . toLocaleLowerCase ( ) !== "false" ) ;
11985
12086 retrieveInclude (
12187 join ( ...[ ...retrievedDirectories , file ] ) ,
122- fixup ,
12388 ) ;
12489 }
12590 }
@@ -135,22 +100,15 @@ const includeHandler: LanguageHandler = {
135100
136101 retrievedFiles . pop ( ) ;
137102 retrievedDirectories . pop ( ) ;
138- fixups . pop ( ) ;
139- addFixup ( filename ) ;
140103 } ;
141104
142105 const params = getShortcodeUnnamedParams ( directive ) ;
143- const options = getShortcodeNamedParams ( directive ) ;
144106 if ( params . length === 0 ) {
145107 throw new Error ( "Include directive needs filename as a parameter" ) ;
146108 }
147109 const includeName = join ( sourceDir , params [ 0 ] ) ;
148110
149- const fixup = options . fixup === undefined
150- ? undefined
151- : ( options . fixup . toLocaleLowerCase ( ) !== "false" ) ;
152-
153- retrieveInclude ( includeName , fixup ) ;
111+ retrieveInclude ( includeName ) ;
154112
155113 return Promise . resolve ( mappedConcat ( textFragments ) ) ;
156114 } ,
0 commit comments