on master help sign in
Merge branch 'master' into debugger
commite7dce9e2e409335a9168aeeda2261e070e015b13 authorEvan Czaplicki <info@elm-lang.org> dateMon 4 Aug 2014, 18:58 (12 years ago) parent4b40219ff02c5c
6 files changed+73−63
Elm.cabal+10−16 changelog.md+1 compiler/Generate/Markdown.hs+34−31 compiler/Type/Type.hs+12−9 runtime/Render/Collage.js+1−1 runtime/Render/Element.js+15−6
Elm.cabal+10−16
@@ -106,23 +106,22 @@ Library
106106 blaze-html >= 0.5 && < 0.8,
107107 blaze-markup,
108108 bytestring,
109+ cheapskate,
109110 cmdargs,
110111 containers >= 0.3,
111112 directory,
112113 filepath,
114+ highlighting-kate,
113115 indents,
114116 language-ecmascript >=0.15 && < 1.0,
115117 language-glsl >= 0.0.2,
116118 mtl >= 2,
117− pandoc >= 1.10,
118119 parsec >= 3.1.1,
119120 pretty,
120− scientific,
121121 text,
122122 transformers >= 0.2,
123123 union-find,
124− unordered-containers,
125− yaml
124+ unordered-containers
126125
127126Executable elm
128127 Main-is: Compiler.hs
@@ -197,23 +196,22 @@ Executable elm
197196 blaze-html >= 0.5 && < 0.8,
198197 blaze-markup,
199198 bytestring,
199+ cheapskate,
200200 cmdargs,
201201 containers >= 0.3,
202202 directory,
203203 filepath,
204+ highlighting-kate,
204205 indents,
205206 language-ecmascript >=0.15 && < 1.0,
206207 language-glsl >= 0.0.2,
207208 mtl >= 2,
208− pandoc >= 1.10,
209209 parsec >= 3.1.1,
210− scientific,
211210 pretty,
212211 text,
213212 transformers >= 0.2,
214213 union-find,
215− unordered-containers,
216− yaml
214+ unordered-containers
217215
218216Executable elm-doc
219217 Main-is: Docs.hs
@@ -249,14 +247,11 @@ Executable elm-doc
249247 indents,
250248 language-glsl >= 0.0.2,
251249 mtl >= 2,
252− pandoc >= 1.10,
253250 parsec >= 3.1.1,
254251 pretty,
255− scientific,
256252 text,
257253 transformers >= 0.2,
258− union-find,
259− yaml
254+ union-find
260255
261256Test-Suite compiler-tests
262257 Type: exitcode-stdio-1.0
@@ -280,25 +275,24 @@ Test-Suite compiler-tests
280275 blaze-html,
281276 blaze-markup,
282277 bytestring,
278+ cheapskate,
283279 cmdargs,
284280 containers >= 0.3,
285281 directory,
286282 Elm,
287283 filemanip,
288284 filepath,
285+ highlighting-kate,
289286 indents,
290287 language-ecmascript >=0.15 && < 1.0,
291288 language-glsl >= 0.0.2,
292289 mtl >= 2,
293− pandoc >= 1.10,
294290 parsec >= 3.1.1,
295291 pretty,
296− scientific,
297292 text,
298293 transformers >= 0.2,
299294 union-find,
300− unordered-containers,
301− yaml
295+ unordered-containers
302296
303297Test-Suite library-tests
304298 Type: exitcode-stdio-1.0
changelog.md+1
@@ -10,6 +10,7 @@
1010 * Add Maybe.map
1111 * Add --bundle-runtime flag which creates stand-alone Elm programs
1212 * Error on ambiguious use of imported variables
13+ * Replace dependency on Pandoc with cheapskate+kate
1314 * Better architecture for compiler. Uses types to make compilation pipeline
1415 safer, setting things up for giving programmatic access to the AST to
1516 improve editor and IDE support.
compiler/Generate/Markdown.hs+34−31
@@ -1,39 +1,42 @@
11module Generate.Markdown where
22
3−import Text.Pandoc
3+import qualified Cheapskate as CS
4+import qualified Cheapskate.Html as CS
45import qualified Data.Set as Set
6+import qualified Data.Text as Text
7+import qualified Text.Blaze.Html.Renderer.String as Blaze
8+import qualified Text.Highlighting.Kate as Kate
9+
10+import Debug.Trace
11+
12+(|>) :: a -> (a -> b) -> b
13+x |> f = f x
514
615toHtml :: String -> String
7−toHtml = writeHtmlString writeOptions . readMarkdown readOptions
16+toHtml rawMarkdown =
17+ Text.pack rawMarkdown
18+ |> CS.markdown options
19+ |> CS.walk highlightCode
20+ |> CS.renderDoc
21+ |> Blaze.renderHtml
822
9−readOptions =
10− def { readerExtensions = elmExtensions
11− , readerApplyMacros = False
12− }
23+options :: CS.Options
24+options =
25+ CS.Options
26+ { CS.sanitize = False
27+ , CS.allowRawHtml = True
28+ , CS.preserveHardBreaks = False
29+ , CS.debug = False
30+ }
1331
14−writeOptions =
15− def { writerExtensions = elmExtensions
16− , writerHighlight = True
17− }
32+highlightCode :: CS.Block -> CS.Block
33+highlightCode block =
34+ case block of
35+ CS.CodeBlock (CS.CodeAttr lang _info) src ->
36+ Kate.highlightAs (Text.unpack lang) (Text.unpack src)
37+ |> Kate.formatHtmlBlock Kate.defaultFormatOpts
38+ |> Blaze.renderHtml
39+ |> Text.pack
40+ |> CS.HtmlBlock
1841
19−elmExtensions :: Set.Set Extension
20−elmExtensions = Set.fromList
21− [ Ext_raw_html
22− , Ext_fenced_code_blocks
23− , Ext_fenced_code_attributes
24− , Ext_backtick_code_blocks
25− , Ext_inline_code_attributes
26− , Ext_markdown_in_html_blocks
27− , Ext_escaped_line_breaks
28− , Ext_fancy_lists
29− , Ext_startnum
30− , Ext_definition_lists
31− , Ext_example_lists
32− , Ext_all_symbols_escapable
33− , Ext_intraword_underscores
34− , Ext_blank_before_blockquote
35− , Ext_blank_before_header
36− , Ext_auto_identifiers
37− , Ext_header_attributes
38− , Ext_implicit_header_references
39− ]
42+ _ -> block
compiler/Type/Type.hs+12−9
@@ -376,10 +376,13 @@ instance Crawl Descriptor where
376376
377377toSrcType :: Variable -> IO T.CanonicalType
378378toSrcType var =
379− do desc <- UF.descriptor =<< addNames var
380− srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
381− return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
379+ go =<< addNames var
382380 where
381+ go v = do
382+ desc <- UF.descriptor v
383+ srcType <- maybe (backupSrcType desc) termToSrcType (structure desc)
384+ return $ maybe srcType (\name -> T.Aliased name srcType) (alias desc)
385+
383386 backupSrcType desc =
384387 case name desc of
385388 Just v@(Var.Canonical _ x@(c:_))
@@ -394,22 +397,22 @@ toSrcType var =
394397 termToSrcType term =
395398 case term of
396399 App1 a b -> do
397− a' <- toSrcType a
398− b' <- toSrcType b
400+ a' <- go a
401+ b' <- go b
399402 case a' of
400403 T.App f args -> return $ T.App f (args ++ [b'])
401404 _ -> return $ T.App a' [b']
402405
403− Fun1 a b -> T.Lambda <$> toSrcType a <*> toSrcType b
406+ Fun1 a b -> T.Lambda <$> go a <*> go b
404407
405− Var1 a -> toSrcType a
408+ Var1 a -> go a
406409
407410 EmptyRecord1 -> return $ T.Record [] Nothing
408411
409412 Record1 tfields extension -> do
410− fields' <- traverse (mapM toSrcType) tfields
413+ fields' <- traverse (mapM go) tfields
411414 let fields = concat [ map ((,) name) ts | (name,ts) <- Map.toList fields' ]
412− ext' <- dealias <$> toSrcType extension
415+ ext' <- dealias <$> go extension
413416 return $ case ext' of
414417 T.Record fs ext -> T.Record (fs ++ fields) ext
415418 T.Var _ -> T.Record fields (Just ext')
runtime/Render/Collage.js+1−1
@@ -301,7 +301,7 @@ function nodeStepper(w,h,div) {
301301 : (Render.update(kid, kid.oldElement, elem), kids[i]);
302302
303303 node.style.position = 'absolute';
304− node.style.opacity = alpha * form.alpha;
304+ node.style.opacity = alpha * form.alpha * elem.props.opacity;
305305 addTransform(node.style, makeTransform(w, h, form, matrices));
306306 node.oldElement = elem;
307307 ++i;
runtime/Render/Element.js+15−6
@@ -3,9 +3,12 @@ ElmRuntime.Render.Element = function() {
33'use strict';
44
55var Utils = ElmRuntime.use(ElmRuntime.Render.Utils);
6−var newElement = Utils.newElement, colorToCss = Utils.colorToCss,
7− addTransform = Utils.addTransform, removeTransform = Utils.removeTransform,
8− fromList = Utils.fromList, eq = Utils.eq;
6+var newElement = Utils.newElement;
7+var colorToCss = Utils.colorToCss;
8+var addTransform = Utils.addTransform;
9+var removeTransform = Utils.removeTransform;
10+var fromList = Utils.fromList;
11+var eq = Utils.eq;
912
1013function setProps(elem, node) {
1114 var props = elem.props;
@@ -253,7 +256,9 @@ function rawHtml(elem) {
253256 return div;
254257}
255258
256−function render(elem) { return setProps(elem, makeElement(elem)); }
259+function render(elem) {
260+ return setProps(elem, makeElement(elem));
261+}
257262function makeElement(e) {
258263 var elem = e.element;
259264 switch(elem.ctor) {
@@ -267,8 +272,12 @@ function makeElement(e) {
267272}
268273
269274function update(node, curr, next) {
270− if (node.tagName === 'A') { node = node.firstChild; }
271− if (curr.props.id === next.props.id) return updateProps(node, curr, next);
275+ if (node.tagName === 'A') {
276+ node = node.firstChild;
277+ }
278+ if (curr.props.id === next.props.id) {
279+ return updateProps(node, curr, next);
280+ }
272281 if (curr.element.ctor !== next.element.ctor) {
273282 node.parentNode.replaceChild(render(next),node);
274283 return true;