File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed
Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " bright " : patch
3+ " bright-web " : patch
4+ ---
5+
6+ Don't trim all whitespace
Original file line number Diff line number Diff line change @@ -181,21 +181,25 @@ function runExtensionsBeforeHighlight(props: CodeProps): CodeProps {
181181 return newProps
182182}
183183
184+ function trimTrailingNewline ( code : string | null ) : string | undefined {
185+ return code ?. replace ( / \n $ / , "" ) ?? undefined
186+ }
187+
184188function parseChildren (
185189 children : CodeText ,
186190 lang ?: LanguageAlias ,
187191 code ?: string
188192) : Partial < BrightProps > {
189193 if ( typeof children === "object" && children ?. type === "code" ) {
190194 return {
191- code : children . props ?. children ?. trim ( ) ,
195+ code : trimTrailingNewline ( children . props ?. children ) ,
192196 ...getLanguageAndTitle ( children . props ?. className ) ,
193197 }
194198 } else if ( typeof children === "object" ) {
195199 const subProps = React . Children . toArray ( children as any ) . map ( ( c : any ) => {
196200 const codeProps = c . props ?. children ?. props
197201 return {
198- code : codeProps . children ?. trim ( ) ,
202+ code : trimTrailingNewline ( codeProps . children ) ,
199203 ...getLanguageAndTitle ( codeProps . className ) ,
200204 }
201205 } )
Original file line number Diff line number Diff line change @@ -71,3 +71,25 @@ console.log(1) // mark[3:10] red
7171// mark
7272const x = 20
7373```
74+
75+ ## Mark code with space
76+
77+ ```` md
78+ ```
79+
80+
81+ here is some text with leading and trailing spaces
82+ that is working if the two lines are left-aligned.
83+
84+
85+ ```
86+ ````
87+
88+ ```
89+
90+
91+ here is some text with leading and trailing spaces
92+ that is working if the two lines are left-aligned.
93+
94+
95+ ```
You can’t perform that action at this time.
0 commit comments