From ec9b9789b60f0bcfb3c04a3d78d4461b43789663 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-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/md5 create mode 100644 deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/sha512 create mode 100644 stdlib/JuliaSyntaxHighlighting.version diff --git a/NEWS.md b/NEWS.md index d53911040e4d79..b9efed202e36d4 100644 --- a/NEWS.md +++ b/NEWS.md @@ -72,6 +72,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-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/md5 b/deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/md5 new file mode 100644 index 00000000000000..152e624adfa096 --- /dev/null +++ b/deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/md5 @@ -0,0 +1 @@ +e82035353b3770b93880326dbc39eaed diff --git a/deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/sha512 b/deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/sha512 new file mode 100644 index 00000000000000..7fe3a704165b2b --- /dev/null +++ b/deps/checksums/JuliaSyntaxHighlighting-036981df0cce0628515d02d457f16b0b0cec8e1d.tar.gz/sha512 @@ -0,0 +1 @@ +1912792a7576a24bddd965c7ca82d5cb26539486901f238a54611431a5b4218a72c5aa8b50c6adbadbab4bed46e5541ee946d5682a0fc48a96cf9d790f119bea diff --git a/pkgimage.mk b/pkgimage.mk index 58049e9a48f2b5..56b8c6a3d94123 100644 --- a/pkgimage.mk +++ b/pkgimage.mk @@ -96,6 +96,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 ce744aa43d9f54..93668857189af2 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 00000000000000..0006140e195f6a --- /dev/null +++ b/stdlib/JuliaSyntaxHighlighting.version @@ -0,0 +1,4 @@ +JULIASYNTAXHIGHLIGHTING_BRANCH = main +JULIASYNTAXHIGHLIGHTING_SHA1 = 036981df0cce0628515d02d457f16b0b0cec8e1d +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 1c8a2849d75f1e..ebc40c9db2b12a 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 696b24a8f8bf1c..eeb0e085c8790a 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