[Proposal] Add a high-level declarative syntax for diagrams#20
[Proposal] Add a high-level declarative syntax for diagrams#20anko9801 wants to merge 30 commits intoTypsium:masterfrom
Conversation
There was a problem hiding this comment.
I have a question: What is the maximum length of a molecule before the max recursion depth is exceeded? I haven't tried yet, I'm just wondering if this is enough for more complicated examples than the one you showed in the PR
There was a problem hiding this comment.
That's a great point. I've optimized the parser to reduce its stack usage from 13 to 5 depth per nesting level to stay under Typst's hardcoded limit of 80. This allows for up to 11 nesting levels, as any further optimization would come at the cost of code readability and extensibility.
|
I'll take time to look at it more in-depth. It seems like awesome work. Thanks ! Also, maybe skeletize should be able to directly detect a single string instead of doing |
There was a problem hiding this comment.
The tests are made with tytanic. It generates the reference images required for the tests.
…re for molecule-ring tests
…r outgoing direction
This pull request introduces a proposal for a new
moleculemodule, intended to offer a more declarative and concise way to write chemical diagrams.The goal is to provide a syntax that is even more intuitive and concise than established tools like ChemFig, allowing the natural way of writing a structure to yield an IUPAC preferred diagram.
This module is designed to integrate with core Alchemist functions, enabling a powerful hybrid workflow. While core Alchemist provides ultimate flexibility through direct cetz integration, this new module, at the cost of that flexibility, offers exceptional conciseness for the most common use cases.
Proposed Features
#molecule("CH3-CH2-OH")) and parse it into a diagram.:labelfor points,::labelfor lines, and alabel: "..."argument) is included to allow for the creation of more complex structures with non-sequential bonds or mechanism arrows.Example Usage
What's implemented
CH3->$C$ $H_3$)NH3+,COO-)^13C,^2H)-=#><:><:|><|)@6(-=-=-(-CH3)=)-CH3)O(lewis: (dots(0), dots(180)))-(angle: 60deg))O:O1=::bond)Refereneces
This is an initial proposal, and I would be very grateful for any feedback, suggestions, or critiques to help improve it. Thank you for your consideration.