on master help sign in
Escape newlines in GLSL blocks

Fixes https://github.com/elm/compiler/issues/1732

commita6568a63f3ffc4defdb608d180b23a0113a89342 authorEvan Czaplicki <evancz@users.noreply.github.com> dateSat 23 Jun 2018, 22:30 (8 years ago) parentf880646
1 file changed+4−2
compiler/src/Parse/Shader.hs+4−2
compiler/src/Parse/Shader.hs+4−2
@@ -1,4 +1,5 @@
11{-# OPTIONS_GHC -Wall #-}
2+{-# LANGUAGE OverloadedStrings #-}
23module Parse.Shader
34 ( shader
45 )
@@ -28,10 +29,11 @@ import qualified Parse.Primitives.Shader as Shader
2829
2930shader :: R.Position -> Parser Src.Expr
3031shader start@(R.Position row col) =
31− do src <- Shader.block
32− shdr <- parseSource row col (Text.unpack src)
32+ do block <- Shader.block
33+ shdr <- parseSource row col (Text.unpack block)
3334 end@(R.Position row2 col2) <- getPosition
3435 let uid = List.intercalate ":" (map show [row, col, row2, col2])
36+ let src = Text.replace "\n" "\\n" (Text.replace "\r\n" "\\n" block)
3537 return (A.at start end (Src.Shader (Text.pack uid) src shdr))
3638
3739