Skip to content

Commit 8d1e7cc

Browse files
authored
Fix {{#if_pure}} syntax issue where indentation and whitespace were not preserved as intended. (#674)
# PR Checklist - [ ] Did you check if it works normally in all models? *ignore this when it dosen't uses models* - [x] Did you check if it works normally in all of web, local and node hosted versions? if it dosen't, did you blocked it in those versions? - [ ] Did you added a type def? # Description This PR fixes an issue where indentation and whitespace inside the {{#if_pure}} syntax were being trimmed. I made an effort to minimize the impact on the parser's existing behavior.
2 parents 2b81950 + 3c8ac16 commit 8d1e7cc

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ts/parser.svelte.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1760,16 +1760,19 @@ function trimLines(p1:string){
17601760
}
17611761

17621762
function blockEndMatcher(p1:string,type:{type:blockMatch,type2?:string},matcherArg:matcherArg):string{
1763+
const p1Trimed = p1.trim()
17631764
switch(type.type){
17641765
case 'pure':
1765-
case 'parse-pure':
17661766
case 'pure-display':
17671767
case 'function':{
1768-
return p1
1768+
return p1Trimed
17691769
}
17701770
case 'parse':
17711771
case 'each':{
1772-
return trimLines(p1)
1772+
return trimLines(p1Trimed)
1773+
}
1774+
case 'parse-pure':{
1775+
return p1
17731776
}
17741777
default:{
17751778
return ''
@@ -1952,7 +1955,7 @@ export function risuChatParser(da:string, arg:{
19521955
}
19531956
blockNestType.delete(nested.length)
19541957
const dat2 = nested.shift()
1955-
const matchResult = blockEndMatcher(dat2.trim(), blockType, matcherObj)
1958+
const matchResult = blockEndMatcher(dat2, blockType, matcherObj)
19561959
if(blockType.type === 'each'){
19571960
const subind = blockType.type2.lastIndexOf(' ')
19581961
const sub = blockType.type2.substring(subind + 1)

0 commit comments

Comments
 (0)