From 8780f335c726e846c3496049dc0f028b1ad9f891 Mon Sep 17 00:00:00 2001 From: Phoenix Eliot Date: Thu, 1 Sep 2016 15:57:54 -0700 Subject: [PATCH] Fix adjusting for whitespace in playercode --- app/views/play/level/tome/Spell.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/play/level/tome/Spell.coffee b/app/views/play/level/tome/Spell.coffee index 1db486b82..ffe9c49c0 100644 --- a/app/views/play/level/tome/Spell.coffee +++ b/app/views/play/level/tome/Spell.coffee @@ -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(/\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 /[\s\S]*<\/playercode>/, '☃' # ☃ serves as placeholder for constructHTML @originalSource = playerCode