Skip to content

Commit

Permalink
Include base KOMA macro/env in KOMA art, book, rept
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Sep 6, 2024
1 parent 62601bd commit 1e32ce9
Show file tree
Hide file tree
Showing 8 changed files with 4,690 additions and 826 deletions.
787 changes: 779 additions & 8 deletions data/packages/class-scrartcl.json

Large diffs are not rendered by default.

787 changes: 779 additions & 8 deletions data/packages/class-scrbook.json

Large diffs are not rendered by default.

787 changes: 779 additions & 8 deletions data/packages/class-scrreprt.json

Large diffs are not rendered by default.

780 changes: 3 additions & 777 deletions dev/packages/class-scrartcl,scrreprt,scrbook.json

Large diffs are not rendered by default.

787 changes: 779 additions & 8 deletions dev/packages/class-scrartcl.json

Large diffs are not rendered by default.

787 changes: 779 additions & 8 deletions dev/packages/class-scrbook.json

Large diffs are not rendered by default.

787 changes: 779 additions & 8 deletions dev/packages/class-scrreprt.json

Large diffs are not rendered by default.

14 changes: 13 additions & 1 deletion dev/parse-cwl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -446,12 +446,24 @@ function findArg(arg: string, regexp: RegExp, index: number): string | false {
* @returns The parsed package object.
*/
function parsePkg(pkgName: string): PackageRaw {
const content = fs.readFileSync(`cwl/${pkgName}.cwl`).toString()
let content = fs.readFileSync(`cwl/${pkgName}.cwl`).toString()
content = handleKomaClasses(pkgName, content)
const pkg: PackageRaw = { deps: [], macros: [], envs: [], keys: {}, args: [] }
parseLines(pkg, content.split('\n'))
return pkg
}

function handleKomaClasses(pkgName: string, content: string): string {
if (!['class-scrartcl', 'class-scrbook', 'class-scrreprt', 'class-scrartcl,scrreprt,scrbook'].includes(pkgName)) {
return content
}
if (pkgName === 'class-scrartcl,scrreprt,scrbook') {
return ''
}
const baseContent = fs.readFileSync('cwl/class-scrartcl,scrreprt,scrbook.cwl').toString()
return baseContent + '\n' + content
}

/**
* Parses an array of file paths and converts CWL files to JSON format.
*
Expand Down

0 comments on commit 1e32ce9

Please sign in to comment.