@@ -26,9 +26,10 @@ function readFile(path) {
2626const args = process . argv . slice ( 2 ) ;
2727
2828const repo = args [ 0 ] ;
29- const target = args [ 1 ] ;
29+ const prefix = args [ 1 ] . substring ( repo . length + 1 ) ;
30+ const target = args [ 2 ] ;
3031
31- const input = `src/submodules/${ repo } /${ target } .md` ;
32+ const input = `src/submodules/${ repo } /${ prefix } ${ target } .md` ;
3233const mainOutput = `obj/${ repo } /${ target } .html` ;
3334const navOutput = `obj/${ repo } /${ target } .nav.html` ;
3435const tocOutput = `obj/${ repo } /${ target } .toc.html` ;
@@ -82,7 +83,7 @@ let mainHtml = await marked.parse(readFile(input), {
8283 }
8384
8485 // Other relative link; point to raw user content.
85- let dirname = path . dirname ( target ) ;
86+ let dirname = path . dirname ( prefix + target ) ;
8687 let href =
8788 `https://raw.githubusercontent.com/deimonn/` +
8889 `${ repo } /refs/heads/master/${ dirname } /${ token . href } `
@@ -181,13 +182,15 @@ if (headings.length == 0) {
181182const categories = { } ;
182183let dictionary = { } ;
183184
184- if ( fs . existsSync ( `src/submodules/${ repo } /categories.json` ) ) {
185- dictionary = JSON . parse ( readFile ( `src/submodules/${ repo } /categories.json` ) ) ;
185+ if ( fs . existsSync ( `src/submodules/${ repo } /${ prefix } categories.json` ) ) {
186+ dictionary = JSON . parse (
187+ readFile ( `src/submodules/${ repo } /${ prefix } categories.json` )
188+ ) ;
186189}
187190
188191for ( const path of listing ) {
189192 // Remove common prefix.
190- const file = path . substring ( 16 + repo . length ) ;
193+ const file = path . substring ( 16 + repo . length + prefix . length ) ;
191194 if ( ! file . includes ( "/" ) ) {
192195 continue ;
193196 }
@@ -227,7 +230,7 @@ for (const [_, category] of Object.entries(categories)) {
227230
228231 for ( const file of category . files ) {
229232 // Current file, highlighted in bold.
230- if ( input == `src/submodules/${ repo } /${ file . path } ` ) {
233+ if ( input == `src/submodules/${ repo } /${ prefix } ${ file . path } ` ) {
231234 navHtml += /* HTML */ `
232235 <li>
233236 <b>${ file . name } </b>
0 commit comments