-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Diagram specific configuration with YAML (Sankey-beta missing diagram-specific configuration and parsing error) #4630
Comments
For new diagrams, config should go in as yaml frontmatter. |
Configuration for Sankey diagrams via yaml are not supported yet, please, use config for now. |
could please show an complex example? |
Like this
I consider that this yaml should not be a part of diagram grammar at all, this must be preprocessed separately |
That is processed separately, isn't part of grammar. |
I'm aware of the simple one, I was referring to the complex (objects) ones, for example configuring
|
@Yokozuna59 It should be Yaml syntax. I know this is kinda weird answer, but it should represent JSON configuration 1 to 1.
I would stick to the first one Just in case: if I am not mistaken this |
Each code should only be for one diagram. So, it doesn't make sense to configure values for other diagrams, i.e., the code is for
In this case, the first approach would be better since all those values would be for the actual diagram. But doing that, it would be hard to strictly limit possible keys, i.e., if
And from an LSP perspective, it would be a nightmare, and the user wouldn't use it since it would provide auto-complete with combining all possible keys, not just the current diagram. So I guess this is the way to go:
Yes, it is. I have forgotten it by mistake. |
If by some reason we would allow to define multiple diagrams per one image the second option (specifying diagram type) would work too. Do we have an issue for adding this yaml-configs? |
Not as far as I'm aware of. |
Would like to hear @aloisklink's take on this. re: having the diagram key in yaml, it should be fine. Removing the key is gonna make things more complicated. |
This comment was marked as resolved.
This comment was marked as resolved.
I decided to renamed the issue to generalize it and keep the discussion, because it is not about Sankey diagrams at all. |
@Yokozuna59 the triple dash block is the standard of frontmatter. We shouldn't deviate from that. |
The YAML frontmatter is currently only used for diagram metadata (like Sticking a MermaidConfig there under a ---
title: My example diagram
config: # or should we call this `init` since that's what the current %%{init: syntax uses?
sankey:
width: 300
--- Another important thing, I think the YAML front-matter shouldn't throw an error if it sees invalid keys (maybe just a warning). The main reason for this is because if a diagram is written for Mermaid v10.5.0, somebody might try to display this same diagram on a different program that uses an older version of Mermaid, that won't recognize the keys. |
|
Where to put |
Maybe a types like this should be fine? type Metadata = {
title?: string;
accTitle?: string;
accDescr?: string;
}
type PossibleDiagramConfig = {
Record<string, Record<string, number | string | boolean>>;
}
type YAML = MermaidConfig & PossibleDiagramConfig & Metadata; Although some attributes in |
I'm thinking we'd have a file like import type {MermaidConfig} from "./config.types.js";
type DiagramFrontmatter = {
title?: string;
accTitle?: string;
accDescr?: string;
config?: MermaidConfig;
}; The diagram config is already defined as part of the Defining it as |
@sidharthv96 While working in the new langium parser, I found out it support multi mode grammar (the ability to apply some rule on specific parts). To use the multi-mode grammar, there should be starting (pushing) and ending (popping) rules to switch between modes. I could to set the That's why using Just to make sure, we officially dropping directives, right? So we don't have to create a mode for it. |
No, we are not dropping directives. We are deprecating them, so no new features will be added to them. To be clear, we NEVER intentionally break backwards compatibility in syntax. We can make breaking JS-API changes in major releases, but we don't break old syntax (except when using the The YAML frontmatter is currently stripped away from the code before it's sent to the parser, so you can ignore it for now. We can add frontmatter support once we get the diagrams running? |
mermaid is deprecating directives for new diagram types: mermaid-js/mermaid#4630
Description
Sankey-beta diagram parser error when using diagram-specific configuration.
Console output:
Steps to reproduce
Add diagram-specific configuration:
%%{init: {'theme': 'default', 'sankey':{ 'width': 400}}}%%
Screenshots
With diagram-specific configuration:
Without:
Code Sample
Setup
Suggested Solutions
No response
Additional Context
No response
The text was updated successfully, but these errors were encountered: