@@ -122,22 +122,30 @@ literals = mkPattern' match'
122122 [ return $ emit $ lbl <> ": "
123123 , prettyPrintJS' js
124124 ]
125− match (JSComment _ com js) = fmap mconcat $ sequence $
125+ match (JSComment _ com js) = mconcat <$> sequence
126+ [ mconcat <$> forM com comment
127+ , prettyPrintJS' js
128+ ]
129+ match (JSRaw _ js) = return $ emit js
130+ match _ = mzero
131+
132+ comment :: (Emit gen) => Comment -> StateT PrinterState Maybe gen
133+ comment (LineComment com) = fmap mconcat $ sequence $
134+ [ return $ emit "\n"
135+ , currentIndent
136+ , return $ emit "//" <> emit com <> emit "\n"
137+ ]
138+ comment (BlockComment com) = fmap mconcat $ sequence $
126139 [ return $ emit "\n"
127140 , currentIndent
128141 , return $ emit "/**\n"
129142 ] ++
130− map asLine (concatMap commentLines com) ++
143+ map asLine (T.lines com) ++
131144 [ currentIndent
132145 , return $ emit " */\n"
133146 , currentIndent
134− , prettyPrintJS' js
135147 ]
136148 where
137− commentLines :: Comment -> [Text]
138− commentLines (LineComment s) = [s]
139− commentLines (BlockComment s) = T.lines s
140−
141149 asLine :: (Emit gen) => Text -> StateT PrinterState Maybe gen
142150 asLine s = do
143151 i <- currentIndent
@@ -150,8 +158,6 @@ literals = mkPattern' match'
150158 Nothing -> case T.uncons t of
151159 Just (x, xs) -> x `T.cons` removeComments xs
152160 Nothing -> ""
153− match (JSRaw _ js) = return $ emit js
154− match _ = mzero
155161
156162conditional :: Pattern PrinterState JS ((Maybe SourceSpan, JS, JS), JS)
157163conditional = mkPattern match