@@ -3,7 +3,7 @@ import type { BundledLanguage } from "shiki";
3
3
import type { StepNameType , DataFixture } from "./types" ;
4
4
import type { ExtendedTestCaseSnapshot } from "./types" ;
5
5
6
- import { renderClipboard , renderError } from "./renderHtml" ;
6
+ import { renderClipboard } from "./renderHtml" ;
7
7
import { getDecorations } from "./helpers/decorations" ;
8
8
9
9
/**
@@ -44,38 +44,23 @@ function createHtmlGenerator(data: DataFixture) {
44
44
console . error ( `Error in ${ stepName } ${ raw . command . spokenForm } ` ) ;
45
45
return "Error" ;
46
46
}
47
- const decorations = await getDecorations ( { snapshot : state , command } ) ;
47
+ const extendedState = { ...state , stepName } ;
48
+ const decorations = await getDecorations ( { snapshot : extendedState , command } ) ;
48
49
const { documentContents } = state ;
49
50
const htmlArray : string [ ] = [ ] ;
50
51
let codeBody ;
51
- const errorLevels = [
52
- "excludes thatMarks sourceMarks selectionRanges ideFlashes" ,
53
- "excludes thatMarks sourceMarks selectionRanges" ,
54
- "excludes thatMarks sourceMarks" ,
55
- "excludes thatMarks" ,
56
- "success" ,
57
- ] ;
58
- let errorLevel = errorLevels . length - 1 ;
59
- for ( let i = decorations . length - 1 ; i >= 0 ; i -- ) {
60
- const fallbackDecoration = decorations . slice ( 0 , i ) . flat ( ) ;
61
- errorLevel = i ;
62
- try {
63
- const marker = await createHighlighter ( ) ;
64
- const options = {
65
- theme : "css-variables" ,
66
- lang,
67
- decorations : fallbackDecoration
68
- } ;
69
- codeBody = marker . codeToHtml ( documentContents , options ) ;
70
- htmlArray . push ( codeBody ) ;
71
- break ;
72
- } catch ( error ) {
73
- console . warn ( `"Failed with decorations level ${ i } :"` , command ) ;
74
- console . warn ( fallbackDecoration , error ) ;
75
- }
76
- }
77
- if ( ! codeBody ) {
78
- console . error ( "All fallback levels failed. Unable to generate code body." ) ;
52
+ // Simplified: just try rendering once with all decorations
53
+ try {
54
+ const marker = await createHighlighter ( ) ;
55
+ const options = {
56
+ theme : "css-variables" ,
57
+ lang,
58
+ decorations,
59
+ } ;
60
+ codeBody = marker . codeToHtml ( documentContents , options ) ;
61
+ htmlArray . push ( codeBody ) ;
62
+ } catch ( error ) {
63
+ console . error ( "Failed to generate code body:" , error ) ;
79
64
codeBody = "" ;
80
65
}
81
66
@@ -84,11 +69,6 @@ function createHtmlGenerator(data: DataFixture) {
84
69
htmlArray . push ( clipboardRendered ) ;
85
70
}
86
71
87
- const errorRendered = renderError ( errorLevel , errorLevels ) ;
88
- if ( errorRendered !== "" ) {
89
- htmlArray . push ( errorRendered ) ;
90
- }
91
-
92
72
return { html : htmlArray . join ( "" ) , data : [ decorations ] } ;
93
73
}
94
74
0 commit comments