Skip to content

Commit

Permalink
feat(unified-latex-stringify): create unified latex stringify
Browse files Browse the repository at this point in the history
  • Loading branch information
tefkah committed Mar 9, 2023
0 parents commit 6e7c08f
Show file tree
Hide file tree
Showing 13 changed files with 1,005 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
32 changes: 32 additions & 0 deletions .lib.swcrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://json.schemastore.org/swcrc",
"jsc": {
"target": "es2017",
"parser": {
"syntax": "typescript",
"decorators": true,
"dynamicImport": true
},
"transform": {
"decoratorMetadata": true,
"legacyDecorator": true
},

"externalHelpers": true,
"loose": true
},
"module": {
"type": "es6",
"strict": true,
"noInterop": true
},
"sourceMaps": true,
"exclude": [
"jest.config.ts",
".*.spec.tsx?$",
".*.test.tsx?$",
"./src/jest-setup.ts$",
"./**/jest-setup.ts$",
".*.js$"
]
}
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

76 changes: 76 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# unified-latex-stringify

Plugin for `unified-latex` that takes an `unified-latex` tree and turns it into LaTeX

## Contents

- [unified-latex-stringify](#unified-latex-stringify)
- [Contents](#contents)
- [What is this?](#what-is-this)
- [When should I use this?](#when-should-i-use-this)
- [Install](#install)
- [Use](#use)
- [API](#api)
- [Syntax tree](#syntax-tree)
- [Types](#types)
- [Compatibility](#compatibility)
- [Security](#security)
- [Related](#related)
- [Contribute](#contribute)
- [License](#license)

## What is this?

## When should I use this?

## Install

## Use

## API

## Syntax tree

## Types

## Compatibility

## Security

## Related

## Contribute

## License

GPL-3.0-or-later © Thomas F. K. Jorna

[unified]: https://unifiedjs.com
[unifiedgh]: https://github.com/unifiedjs/unified
[xast-from-xml]: https://github.com/syntax-tree/xast-util-from-xml
[rehype]: https://github.com/rehypejs/rehype
[rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour
[rejour-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-parse
[rejour-stringify]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-stringify
[rejour-move-abstract]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-move-abstract
[rejour-meta]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-meta
[rejour-relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/rejour-relatex
[relatex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex
[relatex-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/relatex-parse
[jast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast
[jast-util-to-texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jast-util-to-texast
[jastscript]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/rejour/jastscript
[texast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast
[texast-util-to-latex]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/relatex/texast-util-to-latex
[hast]: https://github.com/syntax-tree/hast
[xast]: https://github.com/syntax-tree/xast
[mdast]: https://github.com/syntax-tree/mdast
[mdast-markdown]: https://github.com/syntax-tree/mdast-util-to-markdown
[latex-utensils]: https://github.com/tamuratak/latex-utensils
[latexjs]: https://github.com/latexjs/latexjs
[reoff]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff
[reoff-parse]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-parse
[reoff-rejour]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/reoff/reoff-rejour
[ooxast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast
[ooxast]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/ooxast/ooxast-util-to-jast
[unified-latex-stringify]: https://github.com/TrialAndErrorOrg/parsers/tree/main/libs/unified-latex-stringify
23 changes: 23 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const config = {
displayName: 'unified-latex-stringify',
preset: '../../../jest.preset.js',
globals: {
'ts-jest': {
tsconfig: '<rootDir>/tsconfig.spec.json',
useESM: true,
},
},
testEnvironment: 'node',
transform: {
'^.+\\.[tj]sx?$': ['@swc/jest', { swcrc: false }],
},
transformIgnorePatterns: [],
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../../coverage/libs/unified-latex-stringify',
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
}

export default config
36 changes: 36 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "unified-latex-stringify",
"version": "0.0.1",
"license": "GPL-3.0-or-later",
"repository": "https://github.com/TrialAndErrorOrg/unified-latex-stringify",
"homepage": "https://github.com/TrialAndErrorOrg/parsers",
"author": "Thomas F. K. Jorna <[email protected]>",
"type": "module",
"description": "Plugin for `unified-latex` that takes an `unified-latex` tree and turns it into LaTeX",
"keywords": [
"unified",
"unified-latex",
"stringify",
"latex",
"ast"
],
"typedoc": {
"entryPoint": "./src/index.ts",
"readmeFile": "./README.md",
"displayName": "unified-latex-stringify",
"tsconfig": "./tsconfig.lib.json"
},
"exports": {
".": {
"types": "./index.d.ts",
"import": "./index.js"
}
},
"main": "./index.js",
"types": "./index.d.ts",
"files": [
"index.d.ts",
"index.js",
"./lib"
]
}
82 changes: 82 additions & 0 deletions project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "unified-latex-stringify",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/unified-latex/unified-latex-stringify/src",
"projectType": "library",
"targets": {
"build": {
"executor": "better-nx-tsc:tsc",
"outputs": ["{options.outputPath}"],
"options": {
"rootDir": "libs/unified-latex/unified-latex-stringify/src",
"outputPath": "dist/libs/unified-latex/unified-latex-stringify",
"tsConfig": "libs/unified-latex/unified-latex-stringify/tsconfig.lib.json",
"packageJson": "libs/unified-latex/unified-latex-stringify/package.json",
"main": "libs/unified-latex/unified-latex-stringify/src/index.ts",
"assets": ["libs/unified-latex/unified-latex-stringify/*.md"],
"updateBuildableProjectDepsInPackageJson": true,
"clean": true,
"buildableProjectDepsInPackageJsonType": "dependencies"
},
"dependsOn": [
{
"projects": "dependencies",
"target": "build",
"params": "forward"
},
{
"projects": "self",
"target": "lint"
}
]
},
"npm": {
"executor": "ngx-deploy-npm:deploy",
"options": {
"access": "public"
}
},
"version": {
"executor": "@jscutlery/semver:version",
"options": {
"trackDeps": true,
"postTargets": [
"unified-latex-unified-latex-stringify:npm",
"unified-latex-unified-latex-stringify:github",
"unified-latex-unified-latex-stringify:github-standalone"
]
},
"dependsOn": [
{
"target": "version",
"projects": "dependencies",
"params": "forward"
}
]
},
"github": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "${tag}",
"notes": "${notes}",
"repo": "TrialAndErrorOrg/docx-to-vfile"
}
},
"github-standalone": {
"executor": "@jscutlery/semver:github",
"options": {
"tag": "${tag}",
"notes": "${notes}",
"repo": "TrialAndErrorOrg/unified-latex-unified-latex-stringify"
}
},
"readme": {
"executor": "@jote/readme:update-readme",
"options": {
"readme": "libs/unified-latex/unified-latex-stringify/README.md",
"packageJSON": "libs/unified-latex/unified-latex-stringify/package.json"
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './lib/unified-latex-stringify.js'
7 changes: 7 additions & 0 deletions src/lib/unified-latex-stringify.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import unifiedLatexStringify from './unified-latex-stringify.js'

describe('unifiedLatexStringify', () => {
it('should work', () => {
expect(unifiedLatexStringify).toBeDefined()
})
})
15 changes: 15 additions & 0 deletions src/lib/unified-latex-stringify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { toString } from '@unified-latex/unified-latex-util-to-string'
import { Root, Node } from '@unified-latex/unified-latex-types/'

import { CompilerFunction, Plugin } from 'unified'

const unifiedLatexStringify = function unifiedLatexStringify() {
const compiler: CompilerFunction<Node, string> = (tree) => {
// Assume options.
return toString(tree)
}

Object.assign(this, { Compiler: compiler })
} as Plugin<void[], Root, string>

export default unifiedLatexStringify
13 changes: 13 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
10 changes: 10 additions & 0 deletions tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"declaration": true,
"types": ["node"]
},
"exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
"include": ["src/**/*.ts"]
}
18 changes: 18 additions & 0 deletions tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../../dist/out-tsc",
"types": ["jest", "node"]
},
"include": [
"**/*.test.ts",
"**/*.spec.ts",
"**/*.test.tsx",
"**/*.spec.tsx",
"**/*.test.js",
"**/*.spec.js",
"**/*.test.jsx",
"**/*.spec.jsx",
"**/*.d.ts",
]
}

0 comments on commit 6e7c08f

Please sign in to comment.