mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Fix adjusting for whitespace in playercode
This commit is contained in:
parent
6f1019878e
commit
8780f335c7
1 changed files with 1 additions and 1 deletions
|
@ -76,7 +76,7 @@ module.exports = class Spell
|
|||
# Pull apart the structural wrapper code and the player code, remember the wrapper code, and strip indentation on player code.
|
||||
playerCode = @originalSource.match(/<playercode>\n([\s\S]*)\n *<\/playercode>/)[1]
|
||||
playerCodeLines = playerCode.split('\n')
|
||||
indentation = playerCodeLines[0].length - playerCodeLines[0].trim().length
|
||||
indentation = _.min(_.filter(playerCodeLines.map (line) -> line.match(/^\s*/)?[0]?.length))
|
||||
playerCode = (line.substr(indentation) for line in playerCodeLines).join('\n')
|
||||
@wrapperCode = @originalSource.replace /<playercode>[\s\S]*<\/playercode>/, '☃' # ☃ serves as placeholder for constructHTML
|
||||
@originalSource = playerCode
|
||||
|
|
Loading…
Reference in a new issue