Code Monkey home page Code Monkey logo

juliasyntaxhighlighting.jl's Introduction

Julia Syntax Highlighting

The JuliaSyntaxHighlighting package builds on the StyledStrings and JuliaSyntax standard libraries to provide a simple utility for applying syntax highlighting to text.

julia> using JuliaSyntaxHighlighting: highlight, highlight!

julia> highlight("String(reinterpret(UInt8, [0x293a2061696c756a]))")
"String(reinterpret(UInt8, [0x293a2061696c756a]))" # Colored in the REPL

julia> Base.annotations(ans)
11-element Vector{Tuple{UnitRange{Int64}, Pair{Symbol, Any}}}:
 (1:6, :face => :julia_funcall)
 (1:6, :face => :julia_type)
 (7:7, :face => :julia_rainbow_paren_1)
 (8:18, :face => :julia_funcall)
 (19:19, :face => :julia_rainbow_paren_2)
 (20:24, :face => :julia_type)
 (27:27, :face => :julia_rainbow_bracket_1)
 (28:45, :face => :julia_number)
 (46:46, :face => :julia_rainbow_bracket_1)
 (47:47, :face => :julia_rainbow_paren_2)
 (48:48, :face => :julia_rainbow_paren_1)

juliasyntaxhighlighting.jl's People

Contributors

tecosaur avatar

Stargazers

etpinard avatar shiki avatar Orjan Ameye avatar Lasse Peters avatar Claire Foster avatar Laine Taffin Altman avatar  avatar Caleb Allen avatar Navi avatar Peter avatar Ujjwal Panda avatar Adrian Hill avatar Elias Carvalho avatar Jerry Ling avatar

Watchers

Elliot Saba avatar Jeff Bezanson avatar James Cloos avatar David Anthoff avatar Kristoffer Carlsson avatar Keno Fischer avatar Dilum Aluthge avatar Alex Arslan avatar  avatar  avatar

juliasyntaxhighlighting.jl's Issues

Make it look more like this

With that tongue-in-cheek title out of the way, I'm not sure at the moment how to break this down into parts, so posting this just to keep the issue from getting lost.

Should make it look more like this (longer stretches of same/similar color and use same/similar color for same/similar things)

image

rather than this:

image

See #2 (comment) and after for more discussion

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Broken on 1.11

on 1.11.2:

julia> using JuliaSyntaxHighlighting

julia> JuliaSyntaxHighlighting.highlight("sum(1:8)")
ERROR: ArgumentError: Wrong number of arguments to named tuple constructor.
Stacktrace:
  [1] @NamedTuple{region::UnitRange{Int64}, label::Symbol, value}(args::Tuple{UnitRange{Int64}, Pair{Symbol, Any}})
    @ Base ./namedtuple.jl:117
  [2] convert(::Type{@NamedTuple{region::UnitRange{…}, label::Symbol, value}}, t::Tuple{UnitRange{Int64}, Pair{Symbol, Any}})
    @ Base ./namedtuple.jl:182
  [3] setindex!(A::Memory{@NamedTuple{…}}, x::Tuple{UnitRange{…}, Pair{…}}, i1::Int64)
    @ Base ./genericmemory.jl:243
  [4] unsafe_copyto!(dest::Memory{@NamedTuple{…}}, doffs::Int64, src::Memory{Tuple{…}}, soffs::Int64, n::Int64)
    @ Base ./genericmemory.jl:153
  [5] unsafe_copyto!
    @ ./genericmemory.jl:133 [inlined]
  [6] _copyto_impl!
    @ ./array.jl:308 [inlined]
  [7] copyto!
    @ ./array.jl:294 [inlined]
  [8] copyto!
    @ ./array.jl:319 [inlined]
  [9] copyto_axcheck!
    @ ./abstractarray.jl:1167 [inlined]
 [10] Array
    @ ./array.jl:626 [inlined]
 [11] AnnotatedString
    @ ./strings/annotated.jl:104 [inlined]
 [12] highlight(str::String, ast::JuliaSyntax.GreenNode{JuliaSyntax.SyntaxHead})
    @ JuliaSyntaxHighlighting ~/.julia/packages/JuliaSyntaxHighlighting/Vm3KU/src/JuliaSyntaxHighlighting.jl:397
 [13] highlight(str::String)
    @ JuliaSyntaxHighlighting ~/.julia/packages/JuliaSyntaxHighlighting/Vm3KU/src/JuliaSyntaxHighlighting.jl:389
 [14] top-level scope
    @ REPL[5]:1
Some type information was truncated. Use `show(err)` to see complete types.

No CI

It would be nice if this repo had CI that automatically ran the test suite and build documentation on PRs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.