-
-
Notifications
You must be signed in to change notification settings - Fork 65
Mathml tweaks indent #1665
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
base: mathml_tweaks
Are you sure you want to change the base?
Mathml tweaks indent #1665
Conversation
|
I was just waiting for you to acknowledge that you understand that for properties of specific boxes, especially inherent (immutable) properties like nesting level, it may be better to store those in the box, leaving options for more user customizable properties, like the number of spaces per indent level, or the color or font style indicated across several boxes. This is kind of a boundary case here, and there is room for interpretation. |
OK, but nesting level is something that you can evaluate on the fly. And that is how this implementation works. I do not see the need to add that attribute to each specific Also, because the way BoxExpressions are built, to associate a level level to a BoxExpression is not practical. Notice for example that a String (which is a singleton object, and a BoxElement) can appear at different levels. Consider for example the BoxExpression In this expression, the string Consider also this other example: It does not make sense to propagate to the Strings On the other hand, if for some render it is needed to specify the color element by element, it can be done on the fly. |
In the back of my mind, I have been thinking that the "self" parameter under BTW, that's another thing that distinguishes this from the eval routines. In Boxing routines, the objectness of boxes is used, and constantly varies as the boxing, forming, and rendering occur. In |
There is still a misunderstanding, then. Box attributes are indeed supposed to be computed and altered in boxing routines. That is normal.
If you want, maybe I should implement what I suggest, and it will be easier to understand. Or I'll understand why this is not possible. (But if that's the case, we are in a sad position, because I strongly suspect this is the way it should be done, and if done that way, it will reduce the hacky code that is prone to get written when we don't follow conventional patterns.)
Strings and other atoms don't need nesting levels, they are always one more than the level of their parent. Nesting levels, box dimensions and cumulative properties are only needed in the boxes themselves. |
This is a different thing: the name
Indeed, these classes works in a more similar way in which Sympy object does. This is because we do not expect complex custom replacement rules. And when we want to use them into an evaluation, we need to convert them back to (evaluable) Expression objects. |
Yes, so?
For me, to see your implementation would be useful to understand your point. On the other hand, the pattern I followed here is not so unusual: HTML and the way in which graphics in WL are built follow that pattern.
|
|
@rocky, maybe I should reformulate the question: the mathml code generated by this patch is good enough to use it in Mathics3? if it is, we can merge this and have the tests inside. Then we can improve the implementation of how this mathml code is generated, contrasting it against the existing tests. |
|
@rocky, notice that the most laborious thing I had to do in this PR was to update the tests in the YAML file: YAML does not preserve the indentation of the text, unless I put the text as a literal inside quotes. Also, I didn´t find a way to modify parts of a YAML file without spoiling the format, so changes must be done by hand. Maybe you have a better idea on how to store these tests in more readable or automatizable way. |
I'd rather not go down this route, but instead let's see if there is a better foundation to build on. I'll try to come up with some similar but slightly different code. |
So the phrase "But nesting level is something that you can evaluate on the fly" is irrelevant. And there is a misunderstanding. |
BoxExpressions are literal objects, so once you create them, they should not be modified, right? Also, the same box expression could be used as parts of other BoxExpressions, so the level is not one of their attributes. The level is something that you compute in the render step, not in the construction of the box expressions. In any case, I think it worth to see your alternative implementation. |
|
For the most part, the merge conflicts are resolved by changing "self" to "box". |
b46ade2 to
483ecf6
Compare
This PR implements the indentation in MathMLForm. What is missing here is to adjust the tests.