kramdown-syntax_tree_sitter 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a04dc6ceb1cee4150c0c893d87d48bdec1edeea51deb0c8fe7481efc7fb34913
|
4
|
+
data.tar.gz: b8402223f1bc2752fa043e2d20ac3df02a41ba9edb253f09331c3fb61e692425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a11c4e18f4d378b5b8bea1498b77a43a0653184b1d549112d70470f22645eebbf58e74432032485a9dd3146bed3330d97068d8bd2363eb7a71a5fbd86d3d4d4f
|
7
|
+
data.tar.gz: 398ab77b1edc7c48918cdb28001dc9d69c9c965258cd5404eb20ff65323b71fad77ff33e1ded791e27f8e7ec344a76c6d413f1db28db19a7caa1666b5286feaa
|
data/README.md
CHANGED
@@ -23,7 +23,7 @@ hence also requires a compatible [Rust](https://www.rust-lang.org) installation
|
|
23
23
|
function. It is officially compatible with the following environments:
|
24
24
|
|
25
25
|
- **Ruby**: 2.7, 3.0, 3.1, 3.2
|
26
|
-
- **Rust**: 1.
|
26
|
+
- **Rust**: 1.66, 1.67, 1.68, 1.69
|
27
27
|
- **Platforms**: MacOS, Linux
|
28
28
|
|
29
29
|
### Installation
|
@@ -22,9 +22,9 @@ dependencies = [
|
|
22
22
|
|
23
23
|
[[package]]
|
24
24
|
name = "anyhow"
|
25
|
-
version = "1.0.
|
25
|
+
version = "1.0.71"
|
26
26
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
27
|
-
checksum = "
|
27
|
+
checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8"
|
28
28
|
|
29
29
|
[[package]]
|
30
30
|
name = "ascii"
|
@@ -9,6 +9,8 @@ use tree_sitter_highlight::{Error as TSError, HighlightEvent};
|
|
9
9
|
use tree_sitter_highlight::{Highlight, HighlightConfiguration, Highlighter, HtmlRenderer};
|
10
10
|
use tree_sitter_loader::{Config, LanguageConfiguration, Loader};
|
11
11
|
|
12
|
+
use std::collections::HashSet;
|
13
|
+
|
12
14
|
const LOADER_ERROR_MSG: &str = "Error loading Tree-sitter parsers from directory";
|
13
15
|
const NO_LANGUAGE_ERROR_MSG: &str = "Error retrieving language configuration for scope";
|
14
16
|
const NO_HIGHLIGHT_ERROR_MSG: &str = "Error retrieving highlight configuration for scope";
|
@@ -105,10 +107,22 @@ fn render_html(
|
|
105
107
|
Ok(renderer.lines().collect())
|
106
108
|
}
|
107
109
|
|
108
|
-
fn
|
110
|
+
fn highlight_names_for_language(scope: &str, loader: &Loader) -> Result<Vec<String>> {
|
109
111
|
let (language, config) = language_and_configuration(loader, scope)?;
|
110
112
|
let highlight_config = highlight_configuration(language, config, scope)?;
|
111
|
-
Ok(highlight_config.names().
|
113
|
+
Ok(highlight_config.names().to_vec())
|
114
|
+
}
|
115
|
+
|
116
|
+
fn highlight_names(parser_directory: PathBuf) -> Result<Vec<String>> {
|
117
|
+
let loader = loader(parser_directory)?;
|
118
|
+
let highlight_names = loader
|
119
|
+
.get_all_language_configurations()
|
120
|
+
.into_iter()
|
121
|
+
.flat_map(|(config, _)| config.scope.clone())
|
122
|
+
.flat_map(|scope| highlight_names_for_language(&scope, &loader))
|
123
|
+
.flat_map(Vec::into_iter)
|
124
|
+
.collect::<HashSet<_>>();
|
125
|
+
Ok(highlight_names.into_iter().collect())
|
112
126
|
}
|
113
127
|
|
114
128
|
fn highlight_name_styles() -> HashMap<String, Style> {
|
@@ -146,8 +160,8 @@ fn highlight_adapter(
|
|
146
160
|
css_classes: bool,
|
147
161
|
) -> Result<String> {
|
148
162
|
let parsers_dir = PathBuf::from(parsers_dir);
|
149
|
-
let mut loader = loader(parsers_dir)?;
|
150
|
-
let highlight_names = highlight_names(
|
163
|
+
let mut loader = loader(parsers_dir.clone())?;
|
164
|
+
let highlight_names = highlight_names(parsers_dir)?;
|
151
165
|
loader.configure_highlights(&highlight_names);
|
152
166
|
let (language, config) = language_and_configuration(&loader, scope)?;
|
153
167
|
let highlight_config = highlight_configuration(language, config, scope)?;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kramdown-syntax_tree_sitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew T. Biehl
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -52,77 +52,10 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.0.4
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
- - '='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 5.18.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 5.18.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rouge
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 4.1.0
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 4.1.0
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rubocop
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.50.0
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - '='
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.50.0
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: rubocop-minitest
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - '='
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 0.30.0
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - '='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 0.30.0
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: rubocop-rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - '='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.6.0
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - '='
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.6.0
|
125
|
-
description:
|
55
|
+
description: |-
|
56
|
+
This is a syntax highlighter plugin for Kramdown that leverages Tree-sitter's native syntax highlighter to highlight code blocks (and spans) when rendering HTML.
|
57
|
+
|
58
|
+
Tree-sitter is a modern, general-purpose parsing library that outclasses many existing tools at the task of syntax highlighting. This plugin adapts Tree-sitter's native highlighter for Kramdown, so that Tree-sitter's superior highlighting capabilities can be easily leveraged in the context of rendering Markdown.
|
126
59
|
email:
|
127
60
|
executables: []
|
128
61
|
extensions:
|
@@ -147,6 +80,11 @@ licenses:
|
|
147
80
|
- MIT
|
148
81
|
metadata:
|
149
82
|
rubygems_mfa_required: 'true'
|
83
|
+
homepage_uri: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter
|
84
|
+
source_code_uri: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter
|
85
|
+
documentation_uri: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter/blob/main/README.md
|
86
|
+
changelog_uri: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter/blob/main/CHANGELOG.md
|
87
|
+
bug_tracker_uri: https://github.com/andrewtbiehl/kramdown-syntax_tree_sitter/issues
|
150
88
|
post_install_message:
|
151
89
|
rdoc_options: []
|
152
90
|
require_paths:
|
@@ -161,7 +99,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
99
|
- - ">="
|
162
100
|
- !ruby/object:Gem::Version
|
163
101
|
version: '0'
|
164
|
-
requirements:
|
102
|
+
requirements:
|
103
|
+
- |-
|
104
|
+
This plugin is essentially an adapter for the Tree-sitter highlight library and hence requires a compatible Rust installation to function. It is officially compatible with the following environments:
|
105
|
+
|
106
|
+
- Rust: 1.66, 1.67, 1.68, 1.69
|
107
|
+
- Platforms: MacOS, Linux
|
165
108
|
rubygems_version: 3.4.1
|
166
109
|
signing_key:
|
167
110
|
specification_version: 4
|