{"id":19881554,"url":"https://github.com/chifisource/olivehighlighters.jl","last_synced_at":"2026-02-26T04:05:02.389Z","repository":{"id":241112239,"uuid":"804350936","full_name":"ChifiSource/OliveHighlighters.jl","owner":"ChifiSource","description":"highlighters for the olive notebook editor","archived":false,"fork":false,"pushed_at":"2025-02-25T08:30:36.000Z","size":81,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-02-25T08:36:19.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Julia","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChifiSource.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["emmaccode","UnformalPenguin"]}},"created_at":"2024-05-22T12:36:18.000Z","updated_at":"2025-01-25T04:10:25.000Z","dependencies_parsed_at":"2024-05-22T13:51:57.920Z","dependency_job_id":"581a2921-6077-458e-b710-9db420646535","html_url":"https://github.com/ChifiSource/OliveHighlighters.jl","commit_stats":null,"previous_names":["chifisource/olivehighlighters.jl"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChifiSource%2FOliveHighlighters.jl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChifiSource%2FOliveHighlighters.jl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChifiSource%2FOliveHighlighters.jl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChifiSource%2FOliveHighlighters.jl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChifiSource","download_url":"https://codeload.github.com/ChifiSource/OliveHighlighters.jl/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241309104,"owners_count":19941725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-12T17:14:36.633Z","updated_at":"2025-10-23T18:56:19.761Z","avatar_url":"https://github.com/ChifiSource.png","language":"Julia","funding_links":["https://github.com/sponsors/emmaccode","https://github.com/sponsors/UnformalPenguin"],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://github.com/ChifiSource/image_dump/blob/main/olive/0.1/olivehighlighters.png\" width=225\u003e\u003c/img\u003e\n  \n[![version](https://juliahub.com/docs/General/OliveHighlighters/stable/version.svg)](https://juliahub.com/ui/Packages/General/OliveHighlighters)\n[![deps](https://juliahub.com/docs/General/OliveHighlighters/stable/deps.svg)](https://juliahub.com/ui/Packages/General/OliveHighlighters?t=2)[![pkgeval](https://juliahub.com/docs/General/OliveHighlighters/stable/pkgeval.svg)](https://juliahub.com/ui/Packages/General/OliveHighlighters)\n\n[docs](https://chifidocs.com/olive/OliveHighlighters) \n  \n\u003c/div\u003e\n\n`OliveHighlighters` is a [ToolipsServables](https://github.com/ChifiSource/ToolipsServables.jl)-based syntax highlighting system designed *primarily* for [Olive](https://github.com/ChifiSource/Olive.jl). The main objective of this highlighting system is to provide a clean and easy to modify stylized output for syntax in `Olive`, though it could (and has) easily be applied to other projects as well. \n- [get started](#get-started)\n  - [docs](#documentation)\n  - [usage](#usage) \n- [contributing](#contributing)\n```julia\nusing OliveHighlighters\n\ntm = Highlighter(\n\"\"\"function sample_func(x::Any)\n       println(\"you provided the value \\$x\")\n       if typeof(x) \u003c: Real\n         println(\"\\$(x + 5) is the number incremented by 5\")\n       end\n       if typeof(x) == Int64 \u0026\u0026 x \u003e 0\n          for x in 1:x\n             println(\"hello \\$x\")\n          end\n       end\nend\n\"\"\")\n# styling and marking for julia:\nOliveHighlighters.julia_block!(tm)\n\n# use `string` to turn this into HTML:\ndisplay(\"text/html\", string(tm))\n```\n\u003cimg src=\"https://github.com/ChifiSource/image_dump/blob/main/olive/01%20screenshots/Screenshot%20from%202024-12-25%2008-16-33.png?raw=true\"\u003e\u003c/img\u003e\n##### get started\nIs `OliveHighlighters` the right package for you? This package serves a very specific role, presenting highlighted code within the web-browser or notebook as HTML output. This HTML specifically presents itself with in-line styling and clean simplified output. This particular package is created specifically for [Olive](https://github.com/ChifiSource/Olive.jl). `OliveHighlighters` is useful for the following applications:\n- Getting highlighted julia code in a self-hosted `tmd` markdown document.\n- Creating an application which serves highlighted code.\n- Highlighting Julia code for an example within a Data Science notebook or similar HTTP-based development environment.\n###### adding olive highlighters\n`OliveHighlighters` `0.1` is registered to the `Julia/General` registry, we can add it using `Pkg.add`\n```julia\nusing Pkg; Pkg.add(\"OliveHighlighters\")\n```\nFor the latest changes -- sometimes broken -- add the `Unstable` branch. Some of the branches (new) features might not be fully working.\n```julia\nusing Pkg; Pkg.add(\"OliveHighlighters\", rev = \"Unstable\")\n```\n##### documentation\n- All exports are available in the `OliveHighlighters` doc-string.\n- [chifi docs documentation](https://chifidocs.com/olive/OliveHighlighters) [ecosystem](https://chifidocs.com/olive)\n###### usage\nUsage of `OliveHighlighters` revolves around the `TextStyleModifier`, or `Highlighter` type. We create this type and then mutate it by adding our source and using *marking functions*.\n```julia\nusing OliveHighlighters\n\nhl = Highlighter(\"hello world!\")\n\nOliveHighlighters.mark_all!(hl, \"hello\", :hello)\nstyle!(hl, :default, \"color\" =\u003e \"black\")\nstyle!(hl, :hello, \"background-color\" =\u003e \"orange\", \"color\" =\u003e \"black\")\nstring(hl)\n```\n\u003cimg src=\"https://github.com/ChifiSource/image_dump/blob/main/olive/0.1/hlsc/Screenshot%20from%202025-03-05%2009-25-21.png\"\u003e\u003c/img\u003e\n\nNote that in most cases we will need to use `display(\"text/html\", string(hl))` to see our HTML output. The example above is how highlighters are composed, for a full list of marking functions use `?OliveHighlighters`. `OliveHighlighters` also provides complete syntax highlighters for Julia, Markdown, and `TOML`. These are used through `mark_julia!`/`mark_markdown!`/`mark_toml!` and the same equivalent functions for `style_julia!` and so-forth. For Julia specifically, there is also a convenience function which calls both `mark` and `style`, `julia_block!`\n```julia\nusing OliveHighlighters\n\njulia_hl = Highlighter(\"begin end\")\nmd_hl = Highlighter()\nOliveHighlighters.julia_block!(julia_hl)\nOliveHighlighters.style_markdown!(md_hl)\nOliveHighlighters.mark_markdown!(md_hl)\n```\nAlso consider that when we call `set_text!` to change a highlighter's text, this will also clear the highlighter's marks, **but** it will **not** clear the highlighter's styles. This means we can use the same highlighter to highlight multiple code blocks of the same type of input.\n- **marking julia inside of markdown example** (using `ToolipsServables.tmd` and `interpolate!`)\n```julia\nhelp?\u003e ToolipsServables.interpolate!\n  interpolate!(mdcomp::Component{:div}, components::Component{\u003c:Any} ...; keyargs ...) -\u003e ::Nothing\n  interpolate!(comp::Component{:div}, fillfuncs::Pair{String, \u003c:Any} ...) -\u003e ::Nothing\n\n  Interpolates markdown inside the :text of a div (typically created using\n  tmd). The Component{\u003c:Any} and key-word argument dispatch will interpolate\n  in-line code blocks, as well as values with a % before them. The latter\n  function will take a series of strings paired with functions.\n\n  The functions will be passed the String of a code block, the return is\n  another String – the result.\n```\n```julia\nusing OliveHighlighters\nusing OliveHighlighters.ToolipsServables: tmd, interpolate!\n\n# the `julia` below should have three `s, not two.\nmy_md = tmd(\"mydoc\",\n\"\"\"# hello world\n- this is my sample markdown, along with some julia code.\n``julia\n# example julia!\nmutable struct Example\n   x::Int64\nend\n``\n\"\"\")\n\njl_highlighter = Highlighter()\nOliveHighlighters.style_julia!(jl_highlighter)\n\nfunction mark_md_julia(input::String)\n    set_text!(jl_highlighter, input)\n    OliveHighlighters.mark_julia!(jl_highlighter)\n    string(jl_highlighter)::String\nend\n\ninterpolate!(my_md, \"julia\" =\u003e mark_md_julia)\nmy_md # display(\"text/html\", my_md) or display(my_md)\n```\n\n\u003cimg src=\"https://github.com/ChifiSource/image_dump/blob/main/olive/0.1/hlsc/Screenshot%20from%202025-03-05%2009-25-05.png\"\u003e\n\n##### contributing\nThis project, as well as the rest of the `chifi` ecosystem are up for outside or inside contributions! This includes issues, pull-requests or using/sharing `OliveHighlighters` or related projects. Before opening an issue,\n- ensure the issue does not exist\n- ensure the issue can be replicated on the `Unstable` branch\n\nBefore opening a pull request,\n- ensure that you follow the included `Base`-inspired documentation format.\n- Make sure **to pull request to Unstable.**\n\nThanks you all, I really appreciate any help that is shared :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchifisource%2Folivehighlighters.jl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchifisource%2Folivehighlighters.jl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchifisource%2Folivehighlighters.jl/lists"}