Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Redesign #58

Open
Happypig375 opened this issue Sep 13, 2019 · 8 comments
Open

API Redesign #58

Happypig375 opened this issue Sep 13, 2019 · 8 comments
Labels
Status/1. Blocked Requires another issue or pull request to be completed before being ready. Type/Enhancement

Comments

@Happypig375
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
Currently, the APIs for CSharpMath are not intuitive at all.
For example, to convert MathList->TeX, one has to call MathListBuilder.MathListToString which is a static method (not easy to discover), and its name doesn't imply anything about the result being a TeX string at all.

Describe the solution you'd like

  1. Streamline the use of CSharpMath APIs.
SkiaSharp.SKCanvas canvas =;
"\\frac{1}{2}"
.TeXToMathAtoms()
.ToDisplay()
.ToOutput(canvas);
  1. Replace mutable global variables with settings objects.
    e.g. CSharpMath.Atoms.MathAtoms contain multiple dictionaries that act as hidden dependencies. They should be made obvious.

  2. Reduce legacy boilerplate code from iosMath.
    e.g. Why do some math atoms have their respective interfaces? It's not like MathAtoms will have alternate implementations, they are just data containers. If they are to be extended, they can be inherited.
    e.g. Reduce boilerplate folders. They scare new contributors. Most folders in CSharpMath/ contain few files anyway.
    e.g. Remove CSharpMath.Enumerations.MathAtomType. Use pattern matching on types instead.

  3. Simplify the NuGet chain. It's not obvious what CSharpMath.Rendering does based on its name. CSharpMath, CSharpMath.Editor and CSharpMath.Rendering should be merged into one. Typography should be integrated directly into CSharpMath because

.NET font reader library name Can read math layout info for glyphs?
NRasterizer
SixLabors.Fonts
SharpFont
Typography ✔️
Source: https://github.com/Jolg42/awesome-typography#c-2

It's not like there is or will be any other implementations for font reading of math fonts.

Describe alternatives you've considered
Continuing the current API and result in a degraded user experience.

Difficulty: How difficult would it be? (Trivial, Very Easy, Easy, Moderate, Hard, Very Hard, Tedious, Backbreaking)
Very hard. A lot of time will be needed to achieve this.

Additional context
#57

@Smurf-IV
Copy link

Please can you keep the "Core" of the CSharpMath, out of the need for "Rendering and editor" as this allows it to be used for other frameworks, i.e. Services only.

@charlesroddie
Copy link
Collaborator

What are these services and how would CSharpMath be used without rendering?

@Smurf-IV
Copy link

@charlesroddie

  • .Net Core 2
  • Used for Verification of the Latex Format (Hence my questions/problems about round tripping)
  • Then transferred Via the MathList etc. - using internal methods - into different usage and logic trees, dependent on wrapped metadata and context.

@Happypig375
Copy link
Collaborator Author

Other frameworks can still be used.
image

@Happypig375
Copy link
Collaborator Author

Editing capabilities will be baked into MathAtoms.

@charlesroddie
Copy link
Collaborator

Streamline the use of CSharpMath APIs.

Very good but not sure about the example. I don't think that we should add extension methods to string! If you are creating object B from A then B.FromA(a:A) is often better because usually A can be defined without reference to B but not vice versa.

Replace mutable global variables with settings objects.

Sounds good.

Reduce legacy boilerplate code from iosMath.

Great.

Simplify the NuGet chain. It's not obvious what CSharpMath.Rendering does based on its name. CSharpMath, CSharpMath.Editor and CSharpMath.Rendering should be merged into one. Typography should be integrated directly into CSharpMath because

That's not a significant problem for users. If the projects have a natural structure where later projects naturally depend on earlier ones, then having things in separate projects enforces that ordering, unlike C# code in the same project. I don't know if this is the case with the current CSharpMath projects though.

@Happypig375 Happypig375 added the Status/1. Ready This issue has been confirmed and is ready to be worked on. label Jun 1, 2020
@Happypig375
Copy link
Collaborator Author

An update since the original post:

  1. Streamline the use of CSharpMath APIs: Better solved by documentation as in https://github.com/verybadcat/CSharpMath#major-processes-of-drawing-latex. Extension methods would result in pollution as noted by @charlesroddie.
  2. Replace mutable global variables with settings objects: To do. This is required to support \def, \DeclareMathOperator etc.
  3. Reduce legacy boilerplate code from iosMath: Already done as part of the 0.4 update.
  4. Simplify the NuGet chain: Not a good idea as noted by @charlesroddie.

New items:
5. Merge the entirety of CSharpMath.Rendering.Text into CSharpMath.Atom. In LaTeX, \text enables text-mode inside math-mode. With a separate implementation of CSharpMath.Rendering.Text, this is impossible. It is also undesirable to maintain two LaTeX parsers and two LaTeX trees at the same time. Moreover, this results in difference functionality between CSharpMath.Atom and CSharpMath.Rendering.Text, e.g. CSharpMath.Atom supports \colorbox while CSharpMath.Rendering.Text supports \fontsize, when such functionality should be present on both implementations. With #143, the same parser can be reused for both math-mode and text-mode with swappable command dictionaries.

An open question is whether to support (MathList->Text LaTeX) on top of (MathList->Math LaTeX). Math LaTeX seems enough for everyday use.

The remaining items will be done as "Parser refactor (part 2)", blocked on #143.

@Happypig375 Happypig375 added Status/1. Blocked Requires another issue or pull request to be completed before being ready. and removed Status/1. Ready This issue has been confirmed and is ready to be worked on. labels Jul 14, 2020
@Happypig375
Copy link
Collaborator Author

Note for implementing display math inside text: as seen in http://www.dfcd.net/articles/latex/latex.html, we can add a center environment that helps the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status/1. Blocked Requires another issue or pull request to be completed before being ready. Type/Enhancement
Projects
None yet
Development

No branches or pull requests

3 participants