Skip to content

Commit 2ae9e32

Browse files
committed
feat: convert BAM
1 parent dd34957 commit 2ae9e32

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

docs/entry.3bf0104b.js.map

-1
This file was deleted.

docs/entry.3bf0104b.js renamed to docs/entry.4aabd04e.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/entry.4aabd04e.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:foo="http://www.w3.org/2000/svg"><head><meta charset="utf-8"><title>html2purescript</title><style>body{font-family:sans-serif;text-align:center;margin:10px}textarea{width:100%;height:220px}.container{max-width:900px;margin:auto;text-align:left}.title{vertical-align:middle}.title .picker,h1{font-size:20px}label{display:block;color:#ac450a;border-bottom:1px solid #ac450a;margin-bottom:5px}section{margin:20px auto}</style></head><body> <script src="entry.3bf0104b.js"></script> </body></html>
1+
<!doctype html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:foo="http://www.w3.org/2000/svg"><head><meta charset="utf-8"><title>html2purescript</title><style>body{font-family:sans-serif;text-align:center;margin:10px}textarea{width:100%;height:220px}.container{max-width:900px;margin:auto;text-align:left}.title{vertical-align:middle}.title .picker,h1{font-size:20px}label{display:block;color:#ac450a;border-bottom:1px solid #ac450a;margin-bottom:5px}section{margin:20px auto}</style></head><body> <script src="entry.4aabd04e.js"></script> </body></html>

src/Parser/Halogen.purs

+5-5
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ definedClassName :: String -> Array Declaration
6262
definedClassName className =
6363
[ DeclSignature
6464
{ comments: Nothing
65-
, ident: Ident className
65+
, ident: Ident (classNameToFunctionName className)
6666
, type_: TypeConstructor
6767
( SmartQualifiedName__Simple
6868
(mkModuleName $ NonEmptyArray.cons' "Halogen" ["HTML"])
@@ -72,14 +72,14 @@ definedClassName className =
7272
, DeclValue
7373
{ comments: Nothing
7474
, valueBindingFields:
75-
{ name: Ident className
75+
{ name: Ident (classNameToFunctionName className)
7676
, binders: []
7777
, guarded: Unconditional
7878
{ whereBindings: []
7979
, expr:
8080
exprClassNameConstructor
8181
`ExprApp`
82-
( ExprString className )
82+
(ExprString className)
8383
}
8484
}
8585
}
@@ -96,11 +96,11 @@ renderTree =
9696
[name] -> Array.singleton $
9797
(ExprIdent (fromHalogenHP (Ident "class_")))
9898
`ExprApp`
99-
(ExprVar (Ident name))
99+
(ExprVar (Ident (classNameToFunctionName name)))
100100
names' -> Array.singleton $
101101
(ExprIdent (fromHalogenHP (Ident "classes")))
102102
`ExprApp`
103-
(ExprArray $ names' <#> (\name -> ExprVar (Ident name)))
103+
(ExprArray $ names' <#> (\name -> ExprVar (Ident (classNameToFunctionName name))))
104104
Attribute key val -> Array.singleton $
105105
(ExprIdent (fromHalogenHP (Ident key)))
106106
`ExprApp`

src/Parser/Halogen/Utils.purs

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Debug.Trace (spy, trace)
1414
import Text.HTML.Parser (Attribute(..), HTML(..), parseHTML)
1515
import Text.Parsing.StringParser (ParseError)
1616
import Unsafe.Coerce (unsafeCoerce)
17+
import Data.String.Common as String
1718

1819
fromHalogenHH :: forall a. a -> SmartQualifiedName a
1920
fromHalogenHH = SmartQualifiedName__Custom (mkModuleName $ NonEmptyArray.cons' "Halogen" ["HTML"]) (mkModuleName $ NonEmptyArray.cons' "HH" [])
@@ -44,3 +45,7 @@ collectClassNames =
4445
Attribute "class" val -> stringToClasses val
4546
_ -> []
4647
in Array.nub <<< fold <<< map collectClassNamesHtml
48+
49+
-- "--" is BAM style modifier
50+
classNameToFunctionName :: String -> String
51+
classNameToFunctionName = String.replaceAll (String.Pattern "--") (String.Replacement "____") >>> String.replaceAll (String.Pattern "-") (String.Replacement "_")

0 commit comments

Comments
 (0)