From 67f5e9b1ee5a5fa652eaa8cfcaf03a432f9ffc52 Mon Sep 17 00:00:00 2001 From: TEC Date: Sat, 21 Oct 2023 18:02:01 +0800 Subject: [PATCH] Introduce new syntax highlighting stdlib Having this as a standard library allows for syntax highlighting to be used in the Markdown and REPL standard libraries. As a bonus, this provides an easy and canonical way of obtaining syntax highlighted code across the ecosystem. --- NEWS.md | 6 ++++++ .../md5 | 1 + .../sha512 | 1 + pkgimage.mk | 1 + stdlib/.gitignore | 2 ++ stdlib/JuliaSyntaxHighlighting.version | 4 ++++ stdlib/Makefile | 3 ++- stdlib/stdlib.mk | 6 +++--- 8 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/md5 create mode 100644 deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/sha512 create mode 100644 stdlib/JuliaSyntaxHighlighting.version diff --git a/NEWS.md b/NEWS.md index d5ef405b7a913..ce49e1cb23dc9 100644 --- a/NEWS.md +++ b/NEWS.md @@ -107,6 +107,12 @@ Standard library changes * The new `@styled_str` string macro provides a convenient way of creating a `AnnotatedString` with various faces or other attributes applied ([#49586]). +#### JuliaSyntaxHighlighting + +* A new standard library for applying syntax highlighting to Julia code, this + uses `JuliaSyntax` and `StyledStrings` to implement a `highlight` function + that creates an `AnnotatedString` with syntax highlighting applied. + #### Package Manager #### LinearAlgebra diff --git a/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/md5 b/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/md5 new file mode 100644 index 0000000000000..5e99f7453cfe2 --- /dev/null +++ b/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/md5 @@ -0,0 +1 @@ +08230d0801fda3c81927d558452215e4 diff --git a/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/sha512 b/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/sha512 new file mode 100644 index 0000000000000..16d15cdef3104 --- /dev/null +++ b/deps/checksums/JuliaSyntaxHighlighting-4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63.tar.gz/sha512 @@ -0,0 +1 @@ +0386841dcf30ee53f7f95dd3206e1208482507d157aa09739873de2a56e5ca3d7bbf27eccd9f4ed81c1c0fea229673475f6454fe94df0ff960563ca4c29ed36c diff --git a/pkgimage.mk b/pkgimage.mk index 83c66bd94c702..3c741db2c2202 100644 --- a/pkgimage.mk +++ b/pkgimage.mk @@ -94,6 +94,7 @@ $(eval $(call stdlib_builder,Printf,Unicode)) $(eval $(call stdlib_builder,Random,SHA)) $(eval $(call stdlib_builder,Tar,ArgTools,SHA)) $(eval $(call stdlib_builder,DelimitedFiles,Mmap)) +$(eval $(call stdlib_builder,JuliaSyntaxHighlighting,)) # 2-depth packages $(eval $(call stdlib_builder,LLD_jll,Zlib_jll libLLVM_jll Artifacts Libdl)) diff --git a/stdlib/.gitignore b/stdlib/.gitignore index ce744aa43d9f5..93668857189af 100644 --- a/stdlib/.gitignore +++ b/stdlib/.gitignore @@ -27,6 +27,8 @@ /Distributed /StyledStrings-* /StyledStrings +/JuliaSyntaxHighlighting-* +/JuliaSyntaxHighlighting /*_jll/StdlibArtifacts.toml /*/Manifest.toml /*.image diff --git a/stdlib/JuliaSyntaxHighlighting.version b/stdlib/JuliaSyntaxHighlighting.version new file mode 100644 index 0000000000000..4a819d056e70e --- /dev/null +++ b/stdlib/JuliaSyntaxHighlighting.version @@ -0,0 +1,4 @@ +JULIASYNTAXHIGHLIGHTING_BRANCH = main +JULIASYNTAXHIGHLIGHTING_SHA1 = 4110caaf4fcdf0c614fd3ecd7c5bf589ca82ac63 +JULIASYNTAXHIGHLIGHTING_GIT_URL := https://github.com/julialang/JuliaSyntaxHighlighting.jl.git +JULIASYNTAXHIGHLIGHTING_TAR_URL = https://api.github.com/repos/julialang/JuliaSyntaxHighlighting.jl/tarball/$1 diff --git a/stdlib/Makefile b/stdlib/Makefile index 1c8a2849d75f1..ebc40c9db2b12 100644 --- a/stdlib/Makefile +++ b/stdlib/Makefile @@ -47,7 +47,8 @@ STDLIBS = Artifacts Base64 CRC32c Dates FileWatching \ $(JLL_NAMES) STDLIBS_EXT = Pkg Statistics LazyArtifacts LibCURL DelimitedFiles Downloads ArgTools \ - Tar NetworkOptions SuiteSparse SparseArrays StyledStrings SHA Distributed + Tar NetworkOptions SuiteSparse SparseArrays StyledStrings SHA Distributed \ + JuliaSyntaxHighlighting $(foreach module, $(STDLIBS_EXT), $(eval $(call stdlib-external,$(module),$(shell echo $(module) | tr a-z A-Z)))) diff --git a/stdlib/stdlib.mk b/stdlib/stdlib.mk index 696b24a8f8bf1..eeb0e085c8790 100644 --- a/stdlib/stdlib.mk +++ b/stdlib/stdlib.mk @@ -4,9 +4,9 @@ STDLIBS_WITHIN_SYSIMG := \ INDEPENDENT_STDLIBS := \ ArgTools Base64 CRC32c Dates DelimitedFiles Distributed Downloads Future \ - InteractiveUtils LazyArtifacts LibGit2 LibCURL Logging Markdown Mmap \ - NetworkOptions Profile Printf Pkg REPL Serialization SharedArrays SparseArrays \ - Statistics StyledStrings Tar Test TOML Unicode UUIDs \ + InteractiveUtils JuliaSyntaxHighlighting LazyArtifacts LibGit2 LibCURL Logging \ + Markdown Mmap NetworkOptions Profile Printf Pkg REPL Serialization SharedArrays \ + SparseArrays Statistics StyledStrings Tar Test TOML Unicode UUIDs \ dSFMT_jll GMP_jll libLLVM_jll LLD_jll LLVMLibUnwind_jll LibUnwind_jll LibUV_jll \ LibCURL_jll LibSSH2_jll LibGit2_jll nghttp2_jll MozillaCACerts_jll MbedTLS_jll \ MPFR_jll OpenLibm_jll PCRE2_jll p7zip_jll Zlib_jll