|
| 1 | +# Contributing to mathprog-editor |
| 2 | + |
| 3 | +Thank you for your interest in contributing to mathprog-editor! This guide will help you get started. |
| 4 | + |
| 5 | +## Development Setup |
| 6 | + |
| 7 | +1. **Clone the repository** |
| 8 | + ```bash |
| 9 | + git clone https://github.com/jonra/MathProg.git |
| 10 | + cd mathprog-editor |
| 11 | + ``` |
| 12 | + |
| 13 | +2. **Install dependencies** |
| 14 | + ```bash |
| 15 | + npm install |
| 16 | + ``` |
| 17 | + |
| 18 | +3. **Generate the parser** |
| 19 | + ```bash |
| 20 | + npm run grammar |
| 21 | + ``` |
| 22 | + |
| 23 | +4. **Build the project** |
| 24 | + ```bash |
| 25 | + npm run build |
| 26 | + ``` |
| 27 | + |
| 28 | +5. **Run tests** |
| 29 | + ```bash |
| 30 | + npm test |
| 31 | + ``` |
| 32 | + |
| 33 | +6. **Start the dev server** |
| 34 | + ```bash |
| 35 | + npm run dev |
| 36 | + ``` |
| 37 | + Then open `demo/index.html` in your browser. |
| 38 | + |
| 39 | +## Project Structure |
| 40 | + |
| 41 | +- `src/language/` — Lezer grammar, tokenizer, syntax highlighting, autocomplete |
| 42 | +- `src/brackets/` — Rainbow brackets, scope highlighting, mismatch detection |
| 43 | +- `src/math-render/` — MathProg-to-LaTeX converter, KaTeX renderer, side panel |
| 44 | +- `src/lint/` — Error detection with human-friendly messages |
| 45 | +- `src/theme/` — Light and dark editor themes |
| 46 | +- `src/index.ts` — Main exports and convenience `mathProgEditor()` function |
| 47 | +- `demo/` — Interactive demo page |
| 48 | +- `test/` — Test suite |
| 49 | + |
| 50 | +## How to Contribute |
| 51 | + |
| 52 | +### Reporting Bugs |
| 53 | + |
| 54 | +- Use the [GitHub issue tracker](../../issues) |
| 55 | +- Include the MathProg code that triggers the bug |
| 56 | +- Describe expected vs. actual behavior |
| 57 | +- Include browser/OS info if relevant |
| 58 | + |
| 59 | +### Suggesting Features |
| 60 | + |
| 61 | +- Open a discussion or issue describing the use case |
| 62 | +- Explain why existing features don't cover your need |
| 63 | + |
| 64 | +### Submitting Pull Requests |
| 65 | + |
| 66 | +1. Fork the repo and create a feature branch from `main` |
| 67 | +2. Write tests for new functionality |
| 68 | +3. Ensure all tests pass: `npm test` |
| 69 | +4. Ensure the build succeeds: `npm run build` |
| 70 | +5. Write clear commit messages |
| 71 | +6. Open a PR with a description of the changes |
| 72 | + |
| 73 | +### Grammar Changes |
| 74 | + |
| 75 | +The Lezer grammar (`src/language/mathprog.grammar`) is the foundation of the editor. Changes here affect everything downstream. When modifying the grammar: |
| 76 | + |
| 77 | +1. Run `npm run grammar` to regenerate the parser |
| 78 | +2. Verify the grammar test suite passes |
| 79 | +3. Test with real MathProg/GMPL models in the demo page |
| 80 | +4. Check that highlighting, autocomplete, and linting still work |
| 81 | + |
| 82 | +## Code Style |
| 83 | + |
| 84 | +- TypeScript with strict mode |
| 85 | +- No unnecessary abstractions — keep it simple |
| 86 | +- Follow existing patterns in the codebase |
| 87 | + |
| 88 | +## License |
| 89 | + |
| 90 | +By contributing, you agree that your contributions will be licensed under the MIT License. |
0 commit comments