Skip to content

Commit f694a72

Browse files
author
Harshit Singh
authored
fix(transformers): handle YAML comment prefixes correctly for v3 (#1266)
1 parent 140d4bb commit f694a72

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

packages/transformers/src/shared/notation-transformer.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { ShikiTransformer, ShikiTransformerContext } from '@shikijs/core'
22
import type { Element, Text } from 'hast'
33
import type { ParsedComments } from './parse-comments'
4-
import { parseComments, v1ClearEndCommentPrefix } from './parse-comments'
4+
import { parseComments, v1ClearEndCommentPrefix, v3ClearEndCommentPrefix } from './parse-comments'
55

66
export type MatchAlgorithm = 'v1' | 'v3'
77

@@ -67,6 +67,8 @@ export function createCommentNotationTransformer(
6767

6868
if (matchAlgorithm === 'v1')
6969
comment.info[1] = v1ClearEndCommentPrefix(comment.info[1])
70+
else if (matchAlgorithm === 'v3')
71+
comment.info[1] = v3ClearEndCommentPrefix(comment.info[1])
7072

7173
const isEmpty = comment.info[1].trim().length === 0
7274
// ignore comment node

packages/transformers/test/fixtures/diff/1007.yaml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/transformers/test/fixtures/diff/1007.yaml.output.html

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)