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

Add documentation for front matter #4757

Open
ketozhang opened this issue Aug 21, 2023 · 3 comments
Open

Add documentation for front matter #4757

ketozhang opened this issue Aug 21, 2023 · 3 comments
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request

Comments

@ketozhang
Copy link

ketozhang commented Aug 21, 2023

There exist front matter for all diagrams (e.g., #3706), but there are no documentation of this

@ketozhang ketozhang added Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request labels Aug 21, 2023
@ketozhang ketozhang changed the title Add documentation for frontmatter Add documentation for front matter Aug 21, 2023
@ketozhang
Copy link
Author

Looks like there are only two field supported: title and displayMode? @MasonM

export function extractFrontMatter(text: string, db: DiagramDB): string {
const matches = text.match(frontMatterRegex);
if (matches) {
const parsed: FrontMatterMetadata = yaml.load(matches[1], {
// To keep things simple, only allow strings, arrays, and plain objects.
// https://www.yaml.org/spec/1.2/spec.html#id2802346
schema: yaml.FAILSAFE_SCHEMA,
}) as FrontMatterMetadata;
if (parsed?.title) {
db.setDiagramTitle?.(parsed.title);
}
if (parsed?.displayMode) {
db.setDisplayMode?.(parsed.displayMode);
}
return text.slice(matches[0].length);
} else {
return text;
}
}

@sidharthv96
Copy link
Member

sidharthv96 commented Aug 22, 2023

Yes, currently only title and displaymode are supported, but we just added full config support to frontmatter today via #4750.

That has some added documentation

@ringerc
Copy link

ringerc commented Dec 6, 2023

The frontmatter docs at https://mermaid.js.org/config/configuration.html don't link to the actual config schema https://mermaid.js.org/config/schema-docs/config.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Needs to be verified, categorized, etc Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants