Fix adjusting for whitespace in playercode

This commit is contained in:
Phoenix Eliot 2016-09-01 15:57:54 -07:00
parent 6f1019878e
commit 8780f335c7

View file

@ -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