switch deps + markdown & numeral ditch

This commit is contained in:
theofficialomega
2025-08-02 12:25:21 +02:00
parent 8b3c9c9fa6
commit 45304b81e1
7 changed files with 3332 additions and 3323 deletions

View File

@@ -1,4 +1,5 @@
import markdownInclude from 'markdown-include'
import fs from 'fs'
import path from 'path'
export class Markdown {
filepath: string
@@ -8,6 +9,33 @@ export class Markdown {
}
compile() {
markdownInclude.compileFiles(this.filepath)
const config = JSON.parse(fs.readFileSync(this.filepath, 'utf8'))
const workingDir = process.cwd()
config.files.forEach((templateFile: string) => {
const templatePath = path.resolve(workingDir, templateFile)
const content = fs.readFileSync(templatePath, 'utf8')
const processedContent = this.processIncludes(content, workingDir)
if (config.build) {
const outputPath = path.resolve(workingDir, config.build)
fs.writeFileSync(outputPath, processedContent, 'utf8')
}
})
}
private processIncludes(content: string, baseDir: string): string {
const includeRegex = /#include\s+"([^"]+)"/g
return content.replace(includeRegex, (match, includePath) => {
try {
const fullPath = path.resolve(baseDir, includePath)
const includeContent = fs.readFileSync(fullPath, 'utf8')
return this.processIncludes(includeContent, baseDir)
} catch (error) {
console.warn(`Warning: Could not include file ${includePath}: ${error}`)
return match
}
})
}
}