diff --git a/README.md b/README.md index 7507f510..b365cd8e 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ KEMAL_ENV=test crystal spec - [Mosquito](https://github.com/robacarp/mosquito) - A generic background task runner for Crystal applications - [raven.cr](https://github.com/Sija/raven.cr) - Crystal client for [Sentry](https://sentry.io) - [cr-cmark-gfm](https://github.com/amauryt/cr-cmark-gfm) - Crystal C bindings for [cmark-gfm](https://github.com/github/cmark-gfm) -- [noir](https://github.com/MakeNowJust/noir) - Syntax Highlight Library for Crystal +- [tartrazine](https://github.com/ralsina/tartrazine) - Syntax Highlight Library for Crystal - Logo [icon](https://game-icons.net/1x1/lorc/floating-crystal.html) taken from [Game Icons pack](https://game-icons.net/) under CC BY 3.0 license. ## Contributing diff --git a/assets/vendor/code.scss b/assets/vendor/code.scss index cdda48a8..dda5caaa 100644 --- a/assets/vendor/code.scss +++ b/assets/vendor/code.scss @@ -1,363 +1,237 @@ -.highlight, -.highlight .w { +html pre.b { color: var(--code-color); background-color: var(--code-bg-color); } -.highlight .k, -.highlight .kd, -.highlight .kn, -.highlight .kp, -.highlight .kv { - color: #859900; -} -.highlight .kc { - color: #cb4b16; -} -.highlight .kr { - color: #268bd2; -} -.highlight .kt { - color: #dc322f; -} -.highlight .na { - color: #586e75; -} -.highlight .nb { - color: #b58900; -} -.highlight .bp { - color: #268bd2; -} -.highlight .nc { - color: #268bd2; -} -.highlight .no { - color: #cb4b16; -} -.highlight .nd { - color: #268bd2; -} -.highlight .ni { - color: #cb4b16; -} -.highlight .ne { - color: #cb4b16; -} -.highlight .nf { - color: #268bd2; -} -.highlight .nt { - color: #268bd2; -} -.highlight .nv, -.highlight .vc, -.highlight .vg, -.highlight .vi { - color: #268bd2; -} -.highlight .s, -.highlight .sx, -.highlight .ss { - color: #2aa198; -} -.highlight .sb { - color: #586e75; -} -.highlight .sc { - color: #2aa198; -} -.highlight .sd { - color: #586e75; -} -.highlight .s2 { - color: #2aa198; -} -.highlight .se { - color: #cb4b16; -} -.highlight .sh { - color: #586e75; +.b { + font-weight: bold; + tab-size: 8; } -.highlight .si { - color: #268bd2; +.lh { + color: #795da3; + background-color: #f5f5f5; } -.highlight .sr { - color: #dc322f; +.t { + color: #333333; } -.highlight .s1 { - color: #2aa198; +.e { + color: #ed6a43; } -.highlight .m, -.highlight .mf, -.highlight .mh, -.highlight .mi, -.highlight .il, -.highlight .mo, -.highlight .mb, -.highlight .mx { - color: #2aa198; +.c { + color: #969896; } -.highlight .o, -.highlight .ow { - color: #859900; +.cp { + color: #333333; } -.highlight .p, -.highlight .pi { - color: #cb4b16; +.cpf { + color: #183691; } -.highlight .c, -.highlight .cd, -.highlight .cm, -.highlight .c1 { - color: #93a1a1; +.k { + color: #a71d5d; } -.highlight .cp { - color: #859900; +.kt { + color: #ed6a43; } -.highlight .cs { - color: #859900; +.na { + color: #795da3; } -.highlight .gd { - color: #2aa198; +.nb { + color: #ed6a43; } -.highlight .ge { - font-style: italic; +.nbp { + color: #ed6a43; } -.highlight .gr { - color: #dc322f; +.nc { + color: #795da3; } -.highlight .gh { - color: #cb4b16; +.nc { + color: #0086b3; } -.highlight .gi { - color: #859900; +.nd { + color: #0086b3; } -.highlight .gs { - font-weight: bold; +.nf { + color: #795da3; } -.highlight .gu { - color: #cb4b16; +.nn { + color: #795da3; } -.highlight .m, -.highlight .mf, -.highlight .mh, -.highlight .mi, -.highlight .il, -.highlight .mo, -.highlight .mb, -.highlight .mx { - color: #2aa198; +.nt { + color: #a71d5d; } -.highlight .s, -.highlight .sx, -.highlight .ss { - color: #2aa198; +.nv { + color: #795da3; } -.highlight .sb { - color: #586e75; +.nvi { + color: #ed6a43; } -.highlight .sc { - color: #2aa198; +.ln { + color: #0086b3; } -.highlight .sd { - color: #586e75; +.o { + color: #183691; } -.highlight .s2 { - color: #2aa198; +.ow { + color: #a71d5d; } -.highlight .se { - color: #cb4b16; +.l { + color: #183691; } -.highlight .sh { - color: #586e75; +.ls { + color: #183691; } -.highlight .si { - color: #268bd2; +.lsi { + color: #333333; } -.highlight .sr { - color: #dc322f; +.lsr { + color: #183691; } -.highlight .s1 { - color: #2aa198; +.lss { + color: #0086b3; } html.dark { - .highlight .k, - .highlight .kd, - .highlight .kn, - .highlight .kp, - .highlight .kv { - color: #859900; + .e { + color: #f85149; } - .highlight .kc { - color: #cb4b16; + .lh { + background-color: #6e7681; } - .highlight .kr { - color: #268bd2; + .ln { + color: #6e7681; } - .highlight .kt { - color: #dc322f; + .b { + tab-size: 8; } - .highlight .na { - color: #93a1a1; + .k { + color: #ff7b72; } - .highlight .nb { - color: #b58900; + .kc { + color: #79c0ff; } - .highlight .bp { - color: #268bd2; + .kp { + color: #79c0ff; } - .highlight .nc { - color: #268bd2; + .n { + color: #e6edf3; } - .highlight .no { - color: #cb4b16; + .nc { + color: #f0883e; + font-weight: bold; } - .highlight .nd { - color: #268bd2; + .nc { + color: #79c0ff; + font-weight: bold; } - .highlight .ni { - color: #cb4b16; + .nd { + color: #d2a8ff; + font-weight: bold; } - .highlight .ne { - color: #cb4b16; + .ne { + color: #ffa657; } - .highlight .nf { - color: #268bd2; + .ne { + color: #f0883e; + font-weight: bold; } - .highlight .nt { - color: #268bd2; + .nf { + color: #d2a8ff; + font-weight: bold; } - .highlight .nv, - .highlight .vc, - .highlight .vg, - .highlight .vi { - color: #268bd2; + .nl { + color: #79c0ff; + font-weight: bold; } - .highlight .s, - .highlight .sx, - .highlight .ss { - color: #2aa198; + .nn { + color: #ff7b72; } - .highlight .sb { - color: #93a1a1; + .np { + color: #79c0ff; } - .highlight .sc { - color: #2aa198; + .nt { + color: #7ee787; } - .highlight .sd { - color: #93a1a1; + .nv { + color: #79c0ff; } - .highlight .s2 { - color: #2aa198; + .l { + color: #a5d6ff; } - .highlight .se { - color: #cb4b16; + .ld { + color: #79c0ff; } - .highlight .sh { - color: #93a1a1; + .lsa { + color: #79c0ff; } - .highlight .si { - color: #268bd2; + .lsd { + color: #79c0ff; } - .highlight .sr { - color: #dc322f; + .lse { + color: #79c0ff; } - .highlight .s1 { - color: #2aa198; + .lsh { + color: #79c0ff; } - .highlight .m, - .highlight .mf, - .highlight .mh, - .highlight .mi, - .highlight .il, - .highlight .mo, - .highlight .mb, - .highlight .mx { - color: #2aa198; + .lsr { + color: #79c0ff; } - .highlight .o, - .highlight .ow { - color: #859900; + .o { + color: #ff7b72; + font-weight: bold; } - .highlight .p, - .highlight .pi { - color: #cb4b16; + .c { + color: #8b949e; + font-style: italic; } - .highlight .c, - .highlight .cd, - .highlight .cm, - .highlight .c1 { - color: #586e75; + .cs { + color: #8b949e; + font-weight: bold; + font-style: italic; } - .highlight .cp { - color: #859900; + .cp { + color: #8b949e; + font-weight: bold; } - .highlight .cs { - color: #859900; + .g { + color: #e6edf3; } - .highlight .gd { - color: #2aa198; + .gd { + color: #ffa198; + background-color: #490202; } - .highlight .ge { + .ge { font-style: italic; } - .highlight .gr { - color: #dc322f; - } - .highlight .gh { - color: #cb4b16; - } - .highlight .gi { - color: #859900; + .ge { + color: #ffa198; } - .highlight .gs { + .gh { + color: #79c0ff; font-weight: bold; } - .highlight .gu { - color: #cb4b16; + .gi { + color: #56d364; + background-color: #0f5323; } - .highlight .m, - .highlight .mf, - .highlight .mh, - .highlight .mi, - .highlight .il, - .highlight .mo, - .highlight .mb, - .highlight .mx { - color: #2aa198; + .go { + color: #8b949e; } - .highlight .s, - .highlight .sx, - .highlight .ss { - color: #2aa198; + .gp { + color: #8b949e; } - .highlight .sb { - color: #93a1a1; - } - .highlight .sc { - color: #2aa198; - } - .highlight .sd { - color: #93a1a1; - } - .highlight .s2 { - color: #2aa198; - } - .highlight .se { - color: #cb4b16; + .gs { + font-weight: bold; } - .highlight .sh { - color: #93a1a1; + .gs { + color: #79c0ff; } - .highlight .si { - color: #268bd2; + .gt { + color: #ff7b72; } - .highlight .sr { - color: #dc322f; + .gu { + text-decoration: underline; } - .highlight .s1 { - color: #2aa198; + .tw { + color: #6e7681; } } diff --git a/shard.lock b/shard.lock index 62e64338..2a21dd78 100644 --- a/shard.lock +++ b/shard.lock @@ -21,6 +21,14 @@ shards: git: https://github.com/sija/backtracer.cr.git version: 1.2.2 + baked_file_system: + git: https://github.com/ralsina/baked_file_system.git + version: 0.10.0+git.commit.beb373124c7a235cfb9cd94e36849d8168eaa04b + + base58: + git: https://github.com/crystal-china/base58.cr.git + version: 0.1.0+git.commit.2b0564a975171f4507c33251e0c0ab7990459e23 + cache: git: https://github.com/crystal-cache/cache.git version: 0.14.0 @@ -53,6 +61,10 @@ shards: git: https://github.com/schniz/delegator.cr.git version: 0.1.0 + docopt: + git: https://github.com/chenkovsky/docopt.cr.git + version: 0.2.0+git.commit.620fce4f334ff15d7321e5ecb6665ad258fe9297 + dotenv: git: https://github.com/gdotdesign/cr-dotenv.git version: 1.0.0+git.commit.cb70a7111043fa37e09dce3e4b6db17fd5c6ce54 @@ -121,10 +133,6 @@ shards: git: https://github.com/msa7/multi_auth.git version: 1.1.1+git.commit.7a3244200ec0cc34aef6680783eb3d11ce79d84e - noir: - git: https://github.com/makenowjust/noir.git - version: 0.1.0+git.commit.2508cdec22f4ec61e87a19d9ec563b99c0faa1f0 - pg: git: https://github.com/will/crystal-pg.git version: 0.28.0 @@ -149,6 +157,10 @@ shards: git: https://github.com/mamantoha/shards_spec.git version: 0.2.4 + sixteen: + git: https://github.com/ralsina/sixteen.git + version: 0.3.1 + slang: git: https://github.com/jeromegn/slang.git version: 1.7.3+git.commit.f038a6c9725065ffd9b035f9c402390a2150d519 @@ -157,6 +169,10 @@ shards: git: https://github.com/kemalcr/spec-kemal.git version: 1.0.0 + tartrazine: + git: https://github.com/ralsina/tartrazine.git + version: 0.6.4+git.commit.c011bd8347000130c00582227f885c384c1d4dd7 + time_by_example: git: https://github.com/mamantoha/time_by_example.git version: 0.1.0 diff --git a/shard.yml b/shard.yml index 45f24f45..e5a4523e 100644 --- a/shard.yml +++ b/shard.yml @@ -69,8 +69,8 @@ dependencies: cmark: github: amauryt/cr-cmark-gfm version: 0.1.2 - noir: - github: MakeNowJust/noir + tartrazine: + github: ralsina/tartrazine branch: main autolink: github: crystal-community/autolink.cr diff --git a/src/lib/cmark/readme_renderer.cr b/src/lib/cmark/readme_renderer.cr index 513daa28..b7a98c7a 100644 --- a/src/lib/cmark/readme_renderer.cr +++ b/src/lib/cmark/readme_renderer.cr @@ -1,14 +1,6 @@ require "cmark" - require "cadmium_transliterator" - -require "noir" -require "noir/lexers/crystal" -require "noir/lexers/css" -require "noir/lexers/html" -require "noir/lexers/javascript" -require "noir/lexers/json" -require "noir/lexers/yaml" +require "tartrazine" class ReadmeRenderer < Cmark::HTMLRenderer VIDEO_EXTENSIONS = [".webm", ".mp4", ".mov"] @@ -168,42 +160,40 @@ class ReadmeRenderer < Cmark::HTMLRenderer def code_block(node) cr - out %(
"
-      out escape_html(node.literal)
+      # out ">"
+      # out escape_html(node.literal)
     else
       tags = fence_info.split(' ', remove_empty: true)
       language_name = tags[0]
 
       if @options.github_pre_lang?
-        out %( lang="#{escape_html(tags.shift)})
+        # out %( lang="#{escape_html(tags.shift)})
         tags.each { |tag| out %(" data-meta="#{escape_html(tag)}) } if @options.full_info_string?
-        out %(">)
+        # out %(">)
       else
-        out %(>)
+        # out %(">)
       end
 
-      formatter_out : IO = IO::Memory.new
+      if lexer = Tartrazine.lexer(name: language_name)
+        theme = Tartrazine.theme("github-dark")
+        formatter = Tartrazine::Html.new(theme)
+        formatter.standalone = false
 
-      if lexer = Noir.find_lexer(language_name)
-        Noir.highlight(
-          node.literal,
-          lexer: lexer,
-          formatter: Noir::Formatters::HTML.new(formatter_out)
-        )
-        out formatter_out.to_s
+        out formatter.format(node.literal, lexer)
       else
         out escape_html(node.literal)
       end
     end
 
-    out "
\n" + # out "\n" + # out "\n" end private def change_html(html : String) : String