From fa7cce0278be62adae4cf4e42c0a960b4d2ea1b1 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Tue, 29 Aug 2023 22:06:25 +0200 Subject: [PATCH 1/3] Add css colors ju-comment and ju-judoc --- assets/css/source-ayu-light.css | 10 ++- assets/css/source-nord.css | 12 +++- .../Html/Translation/FromTyped/Source.hs | 66 ++++++++++++++----- 3 files changed, 68 insertions(+), 20 deletions(-) diff --git a/assets/css/source-ayu-light.css b/assets/css/source-ayu-light.css index 942f926a27..53c3cfac49 100644 --- a/assets/css/source-ayu-light.css +++ b/assets/css/source-ayu-light.css @@ -31,6 +31,14 @@ body { color: #787b80; } +.ju-comment { + color: #ba919966; +} + +.ju-comment { + color: #8b2252; +} + .ju-var { color: #5c6166; } @@ -65,4 +73,4 @@ footer a { color: gray; font-size: small; font-weight: bold; -} \ No newline at end of file +} diff --git a/assets/css/source-nord.css b/assets/css/source-nord.css index 993832ce38..902686245e 100644 --- a/assets/css/source-nord.css +++ b/assets/css/source-nord.css @@ -39,11 +39,19 @@ body { color: #a4b4d2 } +.ju-comment { + color: #83898d +} + +.ju-judoc { + color: #8fbcbb +} + .ju-number { color: #d8dee9 } -.ju-defined { +.ju-define { font-weight: bold; } @@ -65,4 +73,4 @@ footer a { color: gray; font-size: small; font-weight: bold; -} \ No newline at end of file +} diff --git a/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs b/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs index e9ff3ba603..b4be128aff 100644 --- a/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs +++ b/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs @@ -22,6 +22,20 @@ import Text.Blaze.Html.Renderer.Text qualified as Html import Text.Blaze.Html5 as Html hiding (map) import Text.Blaze.Html5.Attributes qualified as Attr +data CssColor = + JuInductive + | JuConstructor + | JuFunction + | JuAxiom + | JuString + | JuKeyword + | JuDelimiter + | JuVar + | JuFixity + | JuNumber + | JuComment + | JuJudoc + kindSuffix :: HtmlKind -> String kindSuffix = \case HtmlDoc -> "" @@ -248,16 +262,34 @@ go sdt = case sdt of textSpaces :: Int -> Text textSpaces n = Text.replicate n (Text.singleton ' ') +juColor :: CssColor -> Attribute +juColor = Attr.class_ . toStr + where + toStr :: CssColor -> AttributeValue + toStr = \case + JuInductive -> "ju-inductive" + JuConstructor -> "ju-constructor" + JuFunction -> "ju-function" + JuComment -> "ju-comment" + JuJudoc -> "ju-judoc" + JuAxiom -> "ju-axiom" + JuString -> "ju-string" + JuKeyword -> "ju-keyword" + JuDelimiter -> "ju-delimiter" + JuFixity -> "ju-fixity" + JuVar -> "ju-var" + JuNumber -> "ju-number" + putTag :: forall r. (Members '[Reader HtmlOptions] r) => Ann -> Html -> Sem r Html putTag ann x = case ann of AnnKind k -> return (tagKind k x) - AnnLiteralInteger -> return (Html.span ! Attr.class_ "ju-number" $ x) - AnnLiteralString -> return (Html.span ! Attr.class_ "ju-string" $ x) - AnnKeyword -> return (Html.span ! Attr.class_ "ju-keyword" $ x) - AnnUnkindedSym -> return (Html.span ! Attr.class_ "ju-var" $ x) - AnnComment -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add comment class - AnnJudoc -> return (Html.span ! Attr.class_ "ju-var" $ x) -- TODO add judoc class - AnnDelimiter -> return (Html.span ! Attr.class_ "ju-delimiter" $ x) + AnnLiteralInteger -> return (Html.span ! juColor JuNumber $ x) + AnnLiteralString -> return (Html.span ! juColor JuString $ x) + AnnKeyword -> return (Html.span ! juColor JuKeyword $ x) + AnnUnkindedSym -> return (Html.span ! juColor JuVar $ x) + AnnComment -> return (Html.span ! juColor JuComment $ x) + AnnJudoc -> return (Html.span ! juColor JuJudoc $ x) + AnnDelimiter -> return (Html.span ! juColor JuDelimiter $ x) AnnDef tmp ni -> boldDefine <*> tagDef tmp ni AnnRef tmp ni -> tagRef tmp ni AnnCode -> return x @@ -285,17 +317,17 @@ putTag ann x = case ann of tagKind k = Html.span - ! Attr.class_ + ! juColor ( case k of - S.KNameConstructor -> "ju-constructor" - S.KNameInductive -> "ju-inductive" - S.KNameFunction -> "ju-function" - S.KNameLocal -> "ju-var" - S.KNameAxiom -> "ju-axiom" - S.KNameLocalModule -> "ju-var" - S.KNameAlias -> "ju-var" - S.KNameTopModule -> "ju-var" - S.KNameFixity -> "ju-fixity" + S.KNameConstructor -> JuConstructor + S.KNameInductive -> JuInductive + S.KNameFunction -> JuFunction + S.KNameLocal -> JuVar + S.KNameAxiom -> JuAxiom + S.KNameLocalModule -> JuVar + S.KNameAlias -> JuVar + S.KNameTopModule -> JuVar + S.KNameFixity -> JuFixity ) nameIdAttr :: S.NameId -> AttributeValue From 7c8930ccc002c85db637d6c5ad02a261126c8a2a Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Tue, 29 Aug 2023 22:43:32 +0200 Subject: [PATCH 2/3] ormolu --- .../Html/Translation/FromTyped/Source.hs | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs b/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs index b4be128aff..16e4a49fb3 100644 --- a/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs +++ b/src/Juvix/Compiler/Backend/Html/Translation/FromTyped/Source.hs @@ -22,8 +22,8 @@ import Text.Blaze.Html.Renderer.Text qualified as Html import Text.Blaze.Html5 as Html hiding (map) import Text.Blaze.Html5.Attributes qualified as Attr -data CssColor = - JuInductive +data CssColor + = JuInductive | JuConstructor | JuFunction | JuAxiom @@ -265,20 +265,20 @@ go sdt = case sdt of juColor :: CssColor -> Attribute juColor = Attr.class_ . toStr where - toStr :: CssColor -> AttributeValue - toStr = \case - JuInductive -> "ju-inductive" - JuConstructor -> "ju-constructor" - JuFunction -> "ju-function" - JuComment -> "ju-comment" - JuJudoc -> "ju-judoc" - JuAxiom -> "ju-axiom" - JuString -> "ju-string" - JuKeyword -> "ju-keyword" - JuDelimiter -> "ju-delimiter" - JuFixity -> "ju-fixity" - JuVar -> "ju-var" - JuNumber -> "ju-number" + toStr :: CssColor -> AttributeValue + toStr = \case + JuInductive -> "ju-inductive" + JuConstructor -> "ju-constructor" + JuFunction -> "ju-function" + JuComment -> "ju-comment" + JuJudoc -> "ju-judoc" + JuAxiom -> "ju-axiom" + JuString -> "ju-string" + JuKeyword -> "ju-keyword" + JuDelimiter -> "ju-delimiter" + JuFixity -> "ju-fixity" + JuVar -> "ju-var" + JuNumber -> "ju-number" putTag :: forall r. (Members '[Reader HtmlOptions] r) => Ann -> Html -> Sem r Html putTag ann x = case ann of From f6d6f05d30a52cd17ce3a36d1a7d9212ba03b6a4 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Wed, 30 Aug 2023 13:10:08 +0200 Subject: [PATCH 3/3] fix css class name --- assets/css/source-ayu-light.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/css/source-ayu-light.css b/assets/css/source-ayu-light.css index 53c3cfac49..965006f8f9 100644 --- a/assets/css/source-ayu-light.css +++ b/assets/css/source-ayu-light.css @@ -35,7 +35,7 @@ body { color: #ba919966; } -.ju-comment { +.ju-judoc { color: #8b2252; }