Skip to content

Commit

Permalink
Refactored the tokenizer to fix code climite
Browse files Browse the repository at this point in the history
  • Loading branch information
VisLab committed Nov 7, 2024
1 parent f1e9e8d commit 498117c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions parser/tokenizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,19 +359,18 @@ export class HedStringTokenizer {
}
}

checkForBadPlaceholderIssues(i) {
checkForBadPlaceholderIssues() {
const tokenSplit = this.state.currentToken.split(CHARACTERS.PLACEHOLDER)
if (tokenSplit.length === 1) {
// No placeholders to worry about for this tag
return false
} else if (tokenSplit.length > 2) {
// Multiple placeholders
return true
} else if (!tokenSplit[0].endsWith(CHARACTERS.SLASH)) {
// A placeholder must come immediately after a slash
return true
} else if (tokenSplit[1].trim().length > 0 && tokenSplit[1][0] !== CHARACTERS.BLANK) {
// If units, blank must follow placeholder
}
if (
tokenSplit.length > 2 ||
!tokenSplit[0].endsWith(CHARACTERS.SLASH) || // A placeholder must be after a slash
(tokenSplit[1].trim().length > 0 && tokenSplit[1][0] !== CHARACTERS.BLANK)
) {
// If units, blank after placeholder
return true
}
return false
Expand Down

0 comments on commit 498117c

Please sign in to comment.