fix(yaml/tag): prevent yaml role=tag from being stripped & generalize

data-config
This commit is contained in:
2026-09-03 10:39:05 +08:00
parent 5fc2bc5262
commit 80e2b5b209
3 changed files with 14 additions and 16 deletions
+4
View File
@@ -56,12 +56,16 @@ export function parseBlockAttrs(info: string): BlockAttrs {
* Defaults:
* - role is set, no explicit as → "none" (strip — it's metadata)
* - role=spark-table → "md-table" (render as md-table directive)
* - role=tag → "codeblock" (kept for the marked yaml-tag extension)
* - no role, no as → "codeblock" (keep as visible code block)
*/
export function resolveBlockAs(role: string | undefined, as: string | undefined): string {
if (as) return as;
// spark-table blocks render as md-table by default
if (role === "spark-table") return "md-table";
// yaml-defined tag blocks must survive stripping so the
// code-block-yaml-tag marked extension can render them
if (role === "tag") return "codeblock";
if (role) return "none";
return "codeblock";
}