This file outlines how you can contribute to CaTeX.
If you are new to contributing on GitHub, you might want to see the setup section below.
Additionally, please take note of the notes at the end.
Supporting some functionality from the TeX spec requires editing the parser. However,
there are already some abstractions in place that will make this easier.
For example, even though some special characters are not yet integrated (like the end
of line character), the character enum already contains it and matches the spec.
Search for // todo: [<feature>] is unsupported.
comments to find these.
On the flip side, adding support for new functions or symbols is very easy.
Supporting a new function will require 3 steps (matching the three directories: lookup
,
parsing
, and rendering
:
- Add the new function to the lookup. All functions are defined
in
lib/src/lookup/functions.dart
.
First, add the function to theCaTeXFunction
enum (\sum
becomesCaTeXFunction.sum
).
Second, add a name entry tosupportedFunctionNames
, e.g.r'\sum': CaTeXFunction.sum
.
Third, add the function to thesupportedMathFunctions
list if it is supported in math mode and to thesupportedTextFunctions
if it is supported in text mode (it can support both).
Fourth, add the function to the switch statement inlookupFunction
. You will define the node you need to return in step 2, but you can already enter it because the class naming should be<function name>Node
, e.g.SumNode
.
Thus, you can already addreturn SumNode(context)
for this example. If multiple functions can be combined into one handler (see thefonts
function as an example), they can return the same node. - Create the
<function name>Node
class inparsing/functions/<function_name>.dart
.
SeeParsingNode
and its subclasses to understand how to design your subclass. Do not directly subclassParsingNode
. You need to overrideconfigureWidget
andcreateRenderNode
.
You can also view other functions in the directory for reference.
In this step, you will also have to specify the number ofarguments
and thegreediness
value. - Create
Render<function name>
inrendering/functions/<function_name>.dart
. ExtendRenderNode
this time; you need to overrideconfigure
for sizing andrender
.
You can update the code generation to support some more symbols in gen/symbols.dart
.
The file contains a link which has way more symbols predefined than currently supported.
Updating the generation to support these should be straight forward.
- Ensure you have configured an SSH key with GitHub; see GitHub's directions.
- Fork this repository using the "Fork" button in the upper right corner of the GitHub page.
- Clone the forked repo:
git clone [email protected]:<your_github_user_name>/CaTeX.git
- Navigate into the project:
cd CaTeX
- Add this repo as a remote repository:
git remote add upstream [email protected]:simpleclub/CaTeX.git
-
Fetch the latest repo state:
git fetch upstream
-
Create a feature branch:
git checkout upstream/master -b <name_of_your_branch>
-
Now, you can change the code necessary for your patch.
Make sure that you bump the version in
pubspec.yaml
. You must bump the Pubspec version when a new package version should be released and edit theCHANGELOG.md
accordingly.
The version format needs to follow Dart's semantic versioning. You need to take caret syntax into consideration when landing breaking changes. -
Commit your changes:
git commit -am "<commit_message>"
-
Push your changes:
git push origin <name_of_your_branch>
After having followed these steps, you are ready to create a pull request.
The GitHub interface makes this very easy by providing a button on your fork page that creates
a pull request with changes from a recently pushed to branch.
Alternatively, you can also use git pull-request
via GitHub hub.
- Always add tests or confirm that your code is working with current tests.
- Use
flutter format . --fix
to format all code. - Adhere to the lints, i.e. the warnings provided by Dart's linter based on the repo's lint rules.
Runflutter analyze
in order to ensure that you are not missing any warnings or errors. - If you find something that is fundamentally flawed, please propose a better solution - we are open to complete revamps.
We require contributors to sign our Contributor License Agreement (CLA). In order for us to review and merge your code, please follow the link and sign it.