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

[LaTeX] Inherit LaTeX from TeX #3546

Closed

Conversation

deathaxe
Copy link
Collaborator

This PR is an attempt to avoid (future) code duplication when improving TeX/LaTeX.

It extends LaTeX using TeX as base syntax.

I am uncertain whether test coverage is high enough to dedect possible regressions. Hence someone with good LaTeX experience should have a look at it.

jrappen
jrappen previously approved these changes Nov 12, 2022
@jrappen
Copy link
Contributor

jrappen commented Nov 12, 2022

This looks good.

I would've included the jump to v2 for both so extending syntaxes don't have to adjust twice.

This commit extends LaTeX's `begin-end-commands` context to support
Haskell's `\begin{code} ... \end{code}` blocks.

Formerly used `plain-tex` does no longer exist.
@deathaxe
Copy link
Collaborator Author

v2 syntax requires multiple meta scope adjustments and we probably would want to replace all pop: true by pop: 1 then.

That's basically unrelated with just inheriting LaTeX from TeX and would cause trouble (avoidable conflicts) with @ngc92's other PRs.

This WIP PR is more or less meant as inspiration for him to learn how inheritance works and how it hopefully could help avoiding code duplications when reworking/improving LaTeX.

@ngc92
Copy link
Contributor

ngc92 commented Nov 13, 2022

I took a quick look at this. Do we need to have macro-braces as part of LaTeX? Isn't it the same as in TeX?

@deathaxe
Copy link
Collaborator Author

Maybe. This PR is just a starting point. Further work may be needed or useful.

The same context with identical content is already defined in TeX.
Apply an top-down principle to have most basic contexts at the end of a
document and the organizational ones at the beginning - just like a
tree.

Readability may be improved by grouping contexts visually via delimiter
comments. See also: Java, PHP, ...
@deathaxe
Copy link
Collaborator Author

With regards to deathaxe#1 (comment) I've added overrides for braced groups for illustration purpose.

Please note, how we now will see various ...brace.end.latex in expressions re-used from TeX - the vice versa of your concern.

So basically using the base syntax's final scope .tex is probably a better and more generic choice.

Illustrate how `braces` are implemented in both TeX & LaTeX with same
content but different sub-scopes. Re-implementing a context without
meta_prepend/meta_append overrides it completely.
@deathaxe deathaxe force-pushed the pr/latex/extend-latex-from-tex branch from c45df2d to 4f2b78f Compare November 19, 2022 10:28
@ngc92
Copy link
Contributor

ngc92 commented Nov 19, 2022

then I think going with .tex for all braces makes sense.

In any case, what's the plan going forward with this PR. For further changes, it would probably be good to get the inheritance set up soon, so that other improvements can build on it.

Re-arrange contexts to implement the top-down principle.
Group macro related contexts in a MACROS section
@deathaxe
Copy link
Collaborator Author

Added a couple more commits to give some inspiration of possible code structure for supporting inheritance the best we can - just some experiences from other syntaxes.

In general I think of creating a develop/latex branch in sublimehq/Packages repo we could merge smaller PRs into and keep going without touching master as it seems to become some kind of "Rewrite LaTeX" project ... just to reduce noice on master.

Once a final state is achieved we could merge everything into master at once.

Thoughts?

Some final sub scopes changed from .latex to tex due to inheritance.
Hence make Markdown syntax tests a bit more lazy.
@ngc92
Copy link
Contributor

ngc92 commented Nov 19, 2022

sounds good to me. I mainly want to avoid the situation where the changes I'm doing now need to be re-done for the inheritance later on

@deathaxe
Copy link
Collaborator Author

Sure. This PR should just have been an inspiration for you mainly. I'll try to git this content into a develop branch which you can base on furhter work.

@deathaxe deathaxe mentioned this pull request Nov 19, 2022
@deathaxe
Copy link
Collaborator Author

Closing this in favor of the general development branch/PR #3575.

@deathaxe deathaxe closed this Nov 19, 2022
@deathaxe deathaxe deleted the pr/latex/extend-latex-from-tex branch November 19, 2022 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants