ForNeVeR / xaml-math

A collection of .NET libraries for rendering mathematical formulae using the LaTeX typesetting style, for the WPF and Avalonia XAML-based frameworks
MIT License
643 stars 103 forks source link

Give a range of source string to Box #115

Closed yamamoto-reki closed 6 years ago

yamamoto-reki commented 6 years ago

Hello!

I think it would be better Box has range information of source string. Because it is very convenient when making formula editor. What do you think about that ?

Thanks.

ForNeVeR commented 6 years ago

Well, that's a good idea and it's a direction I'd like the project to evolve.

Yes, we could add a source range information to Atoms and, in extension, to Boxes. It shouldn't be too hard to implement (although it'll be a bit tricky in the command handling code because currently it loses the original source information inside of the command).

alexreg commented 6 years ago

Definitely. I think these are generally called source “spans” in compiler terminology. We’d probably want to transition to a proper parser first though, to make the job easier. @Fornever, how far did you get with integrating TeX.NET into this project?

ForNeVeR commented 6 years ago

@alexreg it looks like you missed the word "parser" in your comment ,)

Unfortunately, I haven't integrated anything from TeX.NET. I think I've built the project though, and that's all for now.

yamamoto-reki commented 6 years ago

Actually I've already coded it. Can I do the pull request?

ForNeVeR commented 6 years ago

That's great. Yes, sure, please send a PR!

alexreg commented 6 years ago

@ForNeVeR Yep, oops, that's what happens when I type on mobile... well, you got the point. :-)

ForNeVeR commented 6 years ago

@yamamoto-reki hi, if you need any help on making your first pull request, I'm ready to provide assistance 😄

I can see that you've forked the project and added a commit to address this issue. Are you aware that now you should send a pull request using the "New pull request" button here?

image

yamamoto-reki commented 6 years ago

@ForNeVeR Thank you very much. I was a little nervous because I was the first pull request. As much as possible, I tried hard not to disturb the structure of the original code, how about you?

ForNeVeR commented 6 years ago

@yamamoto-reki you did everything well. Allow me to congratulate you on making your first pull request 🥇

I have a small comment though (no need to change anything right now, just consider for future pull requests): it's advisably to always make new branch in your git repository (e.g. text-spans) and send a pull request from that branch and not directly from master. That'll help you to separate your new changes (if any) from the pull request.

I'll review the changes in more detail a bit later (ETA ≤ 6 hours). At a first glance, your changes are good and I'll likely merge them, so thank you! 👍

yamamoto-reki commented 6 years ago

I'm sorry. I missed out some code on pull request. (Mainly inside of CharAtom.CreateBox().) I'll fix it tomorrow. Also, I correspond to various Atoms / Boxes.

I want to make Formula editor quickly.

ForNeVeR commented 6 years ago

@yamamoto-reki you can push new commits to your master branch and they will automatically be added to your pull request. That's okay, take your time 😄

ForNeVeR commented 6 years ago

@yamamoto-reki also you should take a look at https://github.com/verybadcat/CSharpMath library. I'm not sure what will be better for your formula editor, but I'd like to keep you informed.

Happypig375 commented 6 years ago

CSharpMath currently only has a Xamarin.iOS backend, but I am currently developing a SkiaSharp backend, which will work on Xamarin.Mac+Xamarin.iOS+Xamarin.Android+Windows(WPF or UWP)+Xamarin.Forms, which hopefully will help. :wink:

yamamoto-reki commented 6 years ago

@ForNeVeR @Happypig375 Thank you for telling me the existence of CSharpMath. I would like to refer to it. Perhaps I may be able to help with CSharpMath.

Actually I have already made an editor for LaTeX that can use the formula palette. I am currently using WpfMath for preview.

I think that highlights are synchronized between the preview and mathematical text, and if it can be entered on the preview side, it will be a very rich editor.

Happypig375 commented 6 years ago

/cc @charlesroddie

charlesroddie commented 6 years ago

@yamamoto-reki Very interested in an editor. CSharpMath is a port of iosMath and MathEditor extends iosMath. So there is a path to get an editor to CSharpMath. I only had some initial thoughts on an editor, which I was going to do in F# eventually, but it may be easier to get an editor onto CSharpMath by porting MathEditor.

How far progressed is your own editor and is that also in C#?

alexreg commented 6 years ago

Let's keep discussion here to WPF-Math and it's derivatives, please.

yamamoto-reki commented 6 years ago

@alexreg Thank you. I will discuss it here.

@charlesroddie The Formula Editor I'm creating did not refer to any other editors at all. Development is done in C #.

The formula editor consists of a TextBox, a palette with buttons for inserting and replacing expressions and symbols, and a preview with WpfMath. I implemented it to share the highlight between preview and TextBox.

However, there is a problem with its function, I have not disclosed it to the public. The editor has its own LaTeX parser different from WpfMath. This is to synchronize the preview highlight with the text highlight. However, due to some differences between WpfMath and my parser, this feature was incomplete.

So, I thought that extending this function with WpfMath is correct, proposed here and started the implementation.

By implementing this function you can publish the formula editor.

charlesroddie commented 6 years ago

OK I was looking to have a single visual editor which may have a palette but doesn't show any LaTeX to users or require them to know or use LaTeX. MathQuill does this in the javascript world and MathEditor on iOS. https://github.com/ForNeVeR/wpf-math/issues/105