inkmark 0.2.0 → 0.2.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Cargo.lock +38 -38
- data/ext/inkmark/Cargo.toml +2 -2
- data/ext/inkmark/src/chunks_by_heading.rs +30 -30
- data/ext/inkmark/src/document.rs +1 -1
- data/ext/inkmark/src/emoji.rs +7 -18
- data/ext/inkmark/src/handler.rs +1 -5
- data/ext/inkmark/src/stats.rs +4 -6
- data/ext/inkmark/src/toc.rs +2 -2
- data/lib/inkmark/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57a396edb9b57902c126f56331f56132cae3c00a13208b8ae850d645a19be87d
|
|
4
|
+
data.tar.gz: ff500020da2be1f902c497d56961328b264a49eb0a32027e42364b348fe2db83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4b71c748877beac92c040e23e597c1290dc9b66843ff4f2afa1aa389acf8d4e94093c84c059ef77d1410f1bcb95c49fdcf3ce18b8373ac388e3ee3388e90379f
|
|
7
|
+
data.tar.gz: 1ded4e94b1baa611c54597c371557ec1b438a61a2d7187118db67600c40492b4dc28d88d2878f24ce0eb4ca08774ad50e2a87c62ecda8222c726ed5f203ecbd7
|
data/CHANGELOG.md
CHANGED
data/Cargo.lock
CHANGED
|
@@ -67,9 +67,9 @@ checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
|
|
67
67
|
|
|
68
68
|
[[package]]
|
|
69
69
|
name = "bitflags"
|
|
70
|
-
version = "2.13.
|
|
70
|
+
version = "2.13.2"
|
|
71
71
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
72
|
-
checksum = "
|
|
72
|
+
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
|
73
73
|
|
|
74
74
|
[[package]]
|
|
75
75
|
name = "bstr"
|
|
@@ -92,9 +92,9 @@ dependencies = [
|
|
|
92
92
|
|
|
93
93
|
[[package]]
|
|
94
94
|
name = "cfg-if"
|
|
95
|
-
version = "1.0.
|
|
95
|
+
version = "1.0.5"
|
|
96
96
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
97
|
-
checksum = "
|
|
97
|
+
checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
|
|
98
98
|
|
|
99
99
|
[[package]]
|
|
100
100
|
name = "clang-sys"
|
|
@@ -109,9 +109,9 @@ dependencies = [
|
|
|
109
109
|
|
|
110
110
|
[[package]]
|
|
111
111
|
name = "crc32fast"
|
|
112
|
-
version = "1.5.
|
|
112
|
+
version = "1.5.2"
|
|
113
113
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
114
|
-
checksum = "
|
|
114
|
+
checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
|
|
115
115
|
dependencies = [
|
|
116
116
|
"cfg-if",
|
|
117
117
|
]
|
|
@@ -130,7 +130,7 @@ checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"
|
|
|
130
130
|
dependencies = [
|
|
131
131
|
"proc-macro2",
|
|
132
132
|
"quote",
|
|
133
|
-
"syn 3.0.
|
|
133
|
+
"syn 3.0.6",
|
|
134
134
|
]
|
|
135
135
|
|
|
136
136
|
[[package]]
|
|
@@ -333,7 +333,7 @@ dependencies = [
|
|
|
333
333
|
|
|
334
334
|
[[package]]
|
|
335
335
|
name = "inkmark"
|
|
336
|
-
version = "0.2.
|
|
336
|
+
version = "0.2.1"
|
|
337
337
|
dependencies = [
|
|
338
338
|
"deunicode",
|
|
339
339
|
"emojis",
|
|
@@ -406,9 +406,9 @@ checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
|
|
406
406
|
|
|
407
407
|
[[package]]
|
|
408
408
|
name = "magnus"
|
|
409
|
-
version = "0.
|
|
409
|
+
version = "0.9.0"
|
|
410
410
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
411
|
-
checksum = "
|
|
411
|
+
checksum = "379d50b6eea4ca84074ccd3e551eb9b07f7865194d5b3198325317e9ef78e5e9"
|
|
412
412
|
dependencies = [
|
|
413
413
|
"magnus-macros",
|
|
414
414
|
"rb-sys",
|
|
@@ -418,9 +418,9 @@ dependencies = [
|
|
|
418
418
|
|
|
419
419
|
[[package]]
|
|
420
420
|
name = "magnus-macros"
|
|
421
|
-
version = "0.
|
|
421
|
+
version = "0.9.0"
|
|
422
422
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
423
|
-
checksum = "
|
|
423
|
+
checksum = "4ca70566af98184bb92d4d9853daaf533c1a3418b9570d0547ea44970035f3fe"
|
|
424
424
|
dependencies = [
|
|
425
425
|
"proc-macro2",
|
|
426
426
|
"quote",
|
|
@@ -670,7 +670,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
|
|
670
670
|
dependencies = [
|
|
671
671
|
"proc-macro2",
|
|
672
672
|
"quote",
|
|
673
|
-
"syn 3.0.
|
|
673
|
+
"syn 3.0.6",
|
|
674
674
|
]
|
|
675
675
|
|
|
676
676
|
[[package]]
|
|
@@ -693,15 +693,15 @@ checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
|
|
693
693
|
|
|
694
694
|
[[package]]
|
|
695
695
|
name = "siphasher"
|
|
696
|
-
version = "1.0.
|
|
696
|
+
version = "1.0.4"
|
|
697
697
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
698
|
-
checksum = "
|
|
698
|
+
checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256"
|
|
699
699
|
|
|
700
700
|
[[package]]
|
|
701
701
|
name = "smallvec"
|
|
702
|
-
version = "1.16.
|
|
702
|
+
version = "1.16.2"
|
|
703
703
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
704
|
-
checksum = "
|
|
704
|
+
checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
|
|
705
705
|
|
|
706
706
|
[[package]]
|
|
707
707
|
name = "stable_deref_trait"
|
|
@@ -722,9 +722,9 @@ dependencies = [
|
|
|
722
722
|
|
|
723
723
|
[[package]]
|
|
724
724
|
name = "syn"
|
|
725
|
-
version = "3.0.
|
|
725
|
+
version = "3.0.6"
|
|
726
726
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
727
|
-
checksum = "
|
|
727
|
+
checksum = "8593e8e72159ed2257d083c7a454a85cbf854f37a0966d8d483aff8c8a3ebcee"
|
|
728
728
|
dependencies = [
|
|
729
729
|
"proc-macro2",
|
|
730
730
|
"quote",
|
|
@@ -733,13 +733,13 @@ dependencies = [
|
|
|
733
733
|
|
|
734
734
|
[[package]]
|
|
735
735
|
name = "synstructure"
|
|
736
|
-
version = "0.
|
|
736
|
+
version = "0.14.0"
|
|
737
737
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
738
|
-
checksum = "
|
|
738
|
+
checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"
|
|
739
739
|
dependencies = [
|
|
740
740
|
"proc-macro2",
|
|
741
741
|
"quote",
|
|
742
|
-
"syn
|
|
742
|
+
"syn 3.0.6",
|
|
743
743
|
]
|
|
744
744
|
|
|
745
745
|
[[package]]
|
|
@@ -762,22 +762,22 @@ dependencies = [
|
|
|
762
762
|
|
|
763
763
|
[[package]]
|
|
764
764
|
name = "thiserror"
|
|
765
|
-
version = "2.0.
|
|
765
|
+
version = "2.0.21"
|
|
766
766
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
767
|
-
checksum = "
|
|
767
|
+
checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
|
|
768
768
|
dependencies = [
|
|
769
769
|
"thiserror-impl",
|
|
770
770
|
]
|
|
771
771
|
|
|
772
772
|
[[package]]
|
|
773
773
|
name = "thiserror-impl"
|
|
774
|
-
version = "2.0.
|
|
774
|
+
version = "2.0.21"
|
|
775
775
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
776
|
-
checksum = "
|
|
776
|
+
checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
|
|
777
777
|
dependencies = [
|
|
778
778
|
"proc-macro2",
|
|
779
779
|
"quote",
|
|
780
|
-
"syn 3.0.
|
|
780
|
+
"syn 3.0.6",
|
|
781
781
|
]
|
|
782
782
|
|
|
783
783
|
[[package]]
|
|
@@ -798,9 +798,9 @@ checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
|
|
798
798
|
|
|
799
799
|
[[package]]
|
|
800
800
|
name = "unicode-ident"
|
|
801
|
-
version = "1.0.
|
|
801
|
+
version = "1.0.26"
|
|
802
802
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
803
|
-
checksum = "
|
|
803
|
+
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
|
804
804
|
|
|
805
805
|
[[package]]
|
|
806
806
|
name = "unicode-segmentation"
|
|
@@ -888,13 +888,13 @@ dependencies = [
|
|
|
888
888
|
|
|
889
889
|
[[package]]
|
|
890
890
|
name = "yoke-derive"
|
|
891
|
-
version = "0.8.
|
|
891
|
+
version = "0.8.3"
|
|
892
892
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
893
|
-
checksum = "
|
|
893
|
+
checksum = "33811428bee40dbceb6d545e95754741d17a6aef9a4849f0fd62e2ba4f412a78"
|
|
894
894
|
dependencies = [
|
|
895
895
|
"proc-macro2",
|
|
896
896
|
"quote",
|
|
897
|
-
"syn
|
|
897
|
+
"syn 3.0.6",
|
|
898
898
|
"synstructure",
|
|
899
899
|
]
|
|
900
900
|
|
|
@@ -909,13 +909,13 @@ dependencies = [
|
|
|
909
909
|
|
|
910
910
|
[[package]]
|
|
911
911
|
name = "zerofrom-derive"
|
|
912
|
-
version = "0.1.
|
|
912
|
+
version = "0.1.8"
|
|
913
913
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
914
|
-
checksum = "
|
|
914
|
+
checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"
|
|
915
915
|
dependencies = [
|
|
916
916
|
"proc-macro2",
|
|
917
917
|
"quote",
|
|
918
|
-
"syn
|
|
918
|
+
"syn 3.0.6",
|
|
919
919
|
"synstructure",
|
|
920
920
|
]
|
|
921
921
|
|
|
@@ -949,11 +949,11 @@ checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da"
|
|
|
949
949
|
dependencies = [
|
|
950
950
|
"proc-macro2",
|
|
951
951
|
"quote",
|
|
952
|
-
"syn 3.0.
|
|
952
|
+
"syn 3.0.6",
|
|
953
953
|
]
|
|
954
954
|
|
|
955
955
|
[[package]]
|
|
956
956
|
name = "zlib-rs"
|
|
957
|
-
version = "0.6.
|
|
957
|
+
version = "0.6.8"
|
|
958
958
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
959
|
-
checksum = "
|
|
959
|
+
checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
|
data/ext/inkmark/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "inkmark"
|
|
3
|
-
version = "0.2.
|
|
3
|
+
version = "0.2.1"
|
|
4
4
|
edition = "2021"
|
|
5
5
|
authors = ["Yaroslav Markin <yaroslav@markin.net>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -10,7 +10,7 @@ publish = false
|
|
|
10
10
|
crate-type = ["cdylib"]
|
|
11
11
|
|
|
12
12
|
[dependencies]
|
|
13
|
-
magnus = { version = "0.
|
|
13
|
+
magnus = { version = "0.9.0", default-features = false }
|
|
14
14
|
rb-sys = { version = "0.9.130", features = ["stable-api-compiled-fallback"] }
|
|
15
15
|
pulldown-cmark = { version = "0.13", default-features = false, features = ["html", "simd"] }
|
|
16
16
|
pulldown-cmark-escape = "0.11"
|
|
@@ -54,17 +54,15 @@ pub fn native_chunks_by_heading(
|
|
|
54
54
|
// when there are no headings at all. Emitted as an entry with
|
|
55
55
|
// `heading: nil, level: 0, id: nil`. Skipped entirely when there
|
|
56
56
|
// is no non-empty content before the first heading.
|
|
57
|
-
let
|
|
57
|
+
let content_opts = ContentOptions {
|
|
58
|
+
with_counts: flags.statistics,
|
|
59
|
+
truncate_params: truncate_params.as_ref(),
|
|
60
|
+
};
|
|
58
61
|
let preamble_end = boundaries.first().map(|b| b.start).unwrap_or(events.len());
|
|
59
62
|
if preamble_end > 0 {
|
|
60
63
|
let preamble_events = &events[0..preamble_end];
|
|
61
64
|
if !is_empty_content(preamble_events) {
|
|
62
|
-
result.push(build_preamble_hash(
|
|
63
|
-
ruby,
|
|
64
|
-
preamble_events,
|
|
65
|
-
with_counts,
|
|
66
|
-
truncate_params.as_ref(),
|
|
67
|
-
)?)?;
|
|
65
|
+
result.push(build_preamble_hash(ruby, preamble_events, &content_opts)?)?;
|
|
68
66
|
}
|
|
69
67
|
}
|
|
70
68
|
|
|
@@ -87,16 +85,17 @@ pub fn native_chunks_by_heading(
|
|
|
87
85
|
}
|
|
88
86
|
let breadcrumb: Vec<&str> = ancestors.iter().map(|(_, t)| t.as_str()).collect();
|
|
89
87
|
let heading_text = collect_inline_text(&events[(boundary.start + 1)..boundary.end]);
|
|
88
|
+
// Content = events after End(Heading) up to the next section or
|
|
89
|
+
// end of document. Re-serialized through cmark_write.
|
|
90
|
+
let content_events = &events[(boundary.end + 1)..section_end];
|
|
90
91
|
let hash = build_section_hash(
|
|
91
92
|
ruby,
|
|
92
|
-
|
|
93
|
-
boundary,
|
|
94
|
-
section_end,
|
|
93
|
+
boundary.level,
|
|
95
94
|
&heading_text,
|
|
96
95
|
&breadcrumb,
|
|
96
|
+
content_events,
|
|
97
97
|
&mut dedup,
|
|
98
|
-
|
|
99
|
-
truncate_params.as_ref(),
|
|
98
|
+
&content_opts,
|
|
100
99
|
)?;
|
|
101
100
|
result.push(hash)?;
|
|
102
101
|
ancestors.push((level, heading_text));
|
|
@@ -113,6 +112,13 @@ struct HeadingBoundary {
|
|
|
113
112
|
level: HeadingLevel,
|
|
114
113
|
}
|
|
115
114
|
|
|
115
|
+
/// How each entry's `content` is rendered: optionally truncated, and
|
|
116
|
+
/// optionally accompanied by `character_count` / `word_count`.
|
|
117
|
+
struct ContentOptions<'a> {
|
|
118
|
+
with_counts: bool,
|
|
119
|
+
truncate_params: Option<&'a TruncateParams>,
|
|
120
|
+
}
|
|
121
|
+
|
|
116
122
|
fn find_heading_boundaries(events: &[Event<'_>]) -> Vec<HeadingBoundary> {
|
|
117
123
|
let mut boundaries = Vec::new();
|
|
118
124
|
let mut i = 0;
|
|
@@ -165,8 +171,7 @@ fn find_section_end(boundaries: &[HeadingBoundary], i: usize, events_len: usize)
|
|
|
165
171
|
fn build_preamble_hash(
|
|
166
172
|
ruby: &Ruby,
|
|
167
173
|
events: &[Event<'_>],
|
|
168
|
-
|
|
169
|
-
truncate_params: Option<&TruncateParams>,
|
|
174
|
+
content_opts: &ContentOptions<'_>,
|
|
170
175
|
) -> Result<RHash, Error> {
|
|
171
176
|
let hash = ruby.hash_new();
|
|
172
177
|
hash.aset(ruby.to_symbol("heading"), ())?;
|
|
@@ -176,12 +181,12 @@ fn build_preamble_hash(
|
|
|
176
181
|
// with proper sections so callers can treat every entry alike.
|
|
177
182
|
hash.aset(ruby.to_symbol("breadcrumb"), ruby.ary_new_capa(0))?;
|
|
178
183
|
|
|
179
|
-
let content = match truncate_params {
|
|
184
|
+
let content = match content_opts.truncate_params {
|
|
180
185
|
Some(params) => truncate::truncate_events(events, params),
|
|
181
186
|
None => render_markdown(events),
|
|
182
187
|
};
|
|
183
|
-
if with_counts {
|
|
184
|
-
let (chars, words) = count_post_truncate(events, truncate_params, &content);
|
|
188
|
+
if content_opts.with_counts {
|
|
189
|
+
let (chars, words) = count_post_truncate(events, content_opts.truncate_params, &content);
|
|
185
190
|
hash.aset(ruby.to_symbol("character_count"), chars)?;
|
|
186
191
|
hash.aset(ruby.to_symbol("word_count"), words)?;
|
|
187
192
|
}
|
|
@@ -191,14 +196,12 @@ fn build_preamble_hash(
|
|
|
191
196
|
|
|
192
197
|
fn build_section_hash(
|
|
193
198
|
ruby: &Ruby,
|
|
194
|
-
|
|
195
|
-
boundary: &HeadingBoundary,
|
|
196
|
-
section_end: usize,
|
|
199
|
+
level: HeadingLevel,
|
|
197
200
|
heading_text: &str,
|
|
198
201
|
breadcrumb: &[&str],
|
|
202
|
+
content_events: &[Event<'_>],
|
|
199
203
|
dedup: &mut SlugDeduplicator,
|
|
200
|
-
|
|
201
|
-
truncate_params: Option<&TruncateParams>,
|
|
204
|
+
content_opts: &ContentOptions<'_>,
|
|
202
205
|
) -> Result<RHash, Error> {
|
|
203
206
|
// Slug is the deduplicated slugify of the (filter-applied) heading
|
|
204
207
|
// text, matching the ids `heading_ids` / `toc` would emit for the
|
|
@@ -210,13 +213,9 @@ fn build_section_hash(
|
|
|
210
213
|
dedup.deduplicate(base)
|
|
211
214
|
};
|
|
212
215
|
|
|
213
|
-
// Content = events after End(Heading) up to the next section or
|
|
214
|
-
// end of document. Re-serialized through cmark_write.
|
|
215
|
-
let content_events = &events[(boundary.end + 1)..section_end];
|
|
216
|
-
|
|
217
216
|
let hash = ruby.hash_new();
|
|
218
217
|
hash.aset(ruby.to_symbol("heading"), heading_text)?;
|
|
219
|
-
hash.aset(ruby.to_symbol("level"), toc::level_to_u8(
|
|
218
|
+
hash.aset(ruby.to_symbol("level"), toc::level_to_u8(level))?;
|
|
220
219
|
if id.is_empty() {
|
|
221
220
|
hash.aset(ruby.to_symbol("id"), ())?;
|
|
222
221
|
} else {
|
|
@@ -228,12 +227,13 @@ fn build_section_hash(
|
|
|
228
227
|
}
|
|
229
228
|
hash.aset(ruby.to_symbol("breadcrumb"), breadcrumb_arr)?;
|
|
230
229
|
|
|
231
|
-
let content = match truncate_params {
|
|
230
|
+
let content = match content_opts.truncate_params {
|
|
232
231
|
Some(params) => truncate::truncate_events(content_events, params),
|
|
233
232
|
None => render_markdown(content_events),
|
|
234
233
|
};
|
|
235
|
-
if with_counts {
|
|
236
|
-
let (chars, words) =
|
|
234
|
+
if content_opts.with_counts {
|
|
235
|
+
let (chars, words) =
|
|
236
|
+
count_post_truncate(content_events, content_opts.truncate_params, &content);
|
|
237
237
|
hash.aset(ruby.to_symbol("character_count"), chars)?;
|
|
238
238
|
hash.aset(ruby.to_symbol("word_count"), words)?;
|
|
239
239
|
}
|
data/ext/inkmark/src/document.rs
CHANGED
|
@@ -283,7 +283,7 @@ fn render_to_plain_text(source: &str, cm_opts: pulldown_cmark::Options, flags: F
|
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
let events = apply_filters(parser.collect(), &flags);
|
|
286
|
-
plain_text::write_plain_text(events
|
|
286
|
+
plain_text::write_plain_text(events, &mut buf);
|
|
287
287
|
buf
|
|
288
288
|
}
|
|
289
289
|
|
data/ext/inkmark/src/emoji.rs
CHANGED
|
@@ -16,34 +16,23 @@ use pulldown_cmark::{CowStr, Event, Tag, TagEnd};
|
|
|
16
16
|
/// Tracks code-block nesting depth so shortcodes inside fenced code blocks
|
|
17
17
|
/// are preserved. Inline code (`Event::Code`) is passed through untouched
|
|
18
18
|
/// because we only scan `Event::Text` events.
|
|
19
|
-
pub fn replace(events: &mut
|
|
19
|
+
pub fn replace(events: &mut [Event<'_>]) {
|
|
20
20
|
let mut code_depth: usize = 0;
|
|
21
21
|
|
|
22
|
-
for
|
|
23
|
-
match
|
|
22
|
+
for event in events.iter_mut() {
|
|
23
|
+
match event {
|
|
24
24
|
Event::Start(Tag::CodeBlock(_)) => {
|
|
25
25
|
code_depth += 1;
|
|
26
|
-
continue;
|
|
27
26
|
}
|
|
28
27
|
Event::End(TagEnd::CodeBlock) => {
|
|
29
28
|
code_depth = code_depth.saturating_sub(1);
|
|
30
|
-
continue;
|
|
31
29
|
}
|
|
32
|
-
Event::Text(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// Take ownership of the text so we can feed it to `replace_shortcodes`
|
|
37
|
-
// and emit a new Text event with the result.
|
|
38
|
-
if let Event::Text(text) = std::mem::replace(&mut events[i], Event::SoftBreak) {
|
|
39
|
-
match replace_shortcodes(&text) {
|
|
40
|
-
Some(replaced) => {
|
|
41
|
-
events[i] = Event::Text(CowStr::Boxed(replaced.into_boxed_str()));
|
|
42
|
-
}
|
|
43
|
-
None => {
|
|
44
|
-
events[i] = Event::Text(text);
|
|
30
|
+
Event::Text(text) if code_depth == 0 => {
|
|
31
|
+
if let Some(replaced) = replace_shortcodes(text) {
|
|
32
|
+
*text = CowStr::Boxed(replaced.into_boxed_str());
|
|
45
33
|
}
|
|
46
34
|
}
|
|
35
|
+
_ => {}
|
|
47
36
|
}
|
|
48
37
|
}
|
|
49
38
|
}
|
data/ext/inkmark/src/handler.rs
CHANGED
|
@@ -696,11 +696,7 @@ fn apply_mutations(node: &mut Node, event_obj: Value, _ruby: &Ruby) -> Result<()
|
|
|
696
696
|
Ok(())
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
-
pub fn dispatch_handlers(
|
|
700
|
-
nodes: &mut Vec<Node>,
|
|
701
|
-
handlers: &RHash,
|
|
702
|
-
ruby: &Ruby,
|
|
703
|
-
) -> Result<(), Error> {
|
|
699
|
+
pub fn dispatch_handlers(nodes: &mut [Node], handlers: &RHash, ruby: &Ruby) -> Result<(), Error> {
|
|
704
700
|
for node in nodes.iter_mut() {
|
|
705
701
|
dispatch_handlers(&mut node.children, handlers, ruby)?;
|
|
706
702
|
|
data/ext/inkmark/src/stats.rs
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
//! The collector is the single source of truth for the full-render path.
|
|
17
17
|
//! Two independent Ruby-side knobs consume its output:
|
|
18
18
|
//! - `statistics: true` => scalar counts and language
|
|
19
|
-
//!
|
|
19
|
+
//! detection (`to_statistics_hash`)
|
|
20
20
|
//! - `extract: {...}` => filtered arrays of structured
|
|
21
|
-
//!
|
|
21
|
+
//! records (`to_extracts_hash`)
|
|
22
22
|
|
|
23
23
|
use std::ops::Range;
|
|
24
24
|
|
|
@@ -293,10 +293,8 @@ pub fn collect(events: &[(Event<'_>, Range<usize>)]) -> Stats {
|
|
|
293
293
|
}
|
|
294
294
|
}
|
|
295
295
|
}
|
|
296
|
-
Event::SoftBreak | Event::HardBreak => {
|
|
297
|
-
|
|
298
|
-
text_buf.push(' ');
|
|
299
|
-
}
|
|
296
|
+
Event::SoftBreak | Event::HardBreak if !in_code_block => {
|
|
297
|
+
text_buf.push(' ');
|
|
300
298
|
}
|
|
301
299
|
_ => {}
|
|
302
300
|
}
|
data/ext/inkmark/src/toc.rs
CHANGED
|
@@ -22,7 +22,7 @@ pub struct TocEntry {
|
|
|
22
22
|
pub fn toc_to_markdown(entries: &[TocEntry], max_depth: Option<u8>) -> String {
|
|
23
23
|
let filtered: Vec<&TocEntry> = entries
|
|
24
24
|
.iter()
|
|
25
|
-
.filter(|e| max_depth.
|
|
25
|
+
.filter(|e| max_depth.is_none_or(|max| level_to_u8(e.level) <= max))
|
|
26
26
|
.collect();
|
|
27
27
|
if filtered.is_empty() {
|
|
28
28
|
return String::new();
|
|
@@ -61,7 +61,7 @@ pub fn toc_to_markdown(entries: &[TocEntry], max_depth: Option<u8>) -> String {
|
|
|
61
61
|
pub fn toc_to_html(entries: &[TocEntry], max_depth: Option<u8>) -> String {
|
|
62
62
|
let filtered: Vec<&TocEntry> = entries
|
|
63
63
|
.iter()
|
|
64
|
-
.filter(|e| max_depth.
|
|
64
|
+
.filter(|e| max_depth.is_none_or(|max| level_to_u8(e.level) <= max))
|
|
65
65
|
.collect();
|
|
66
66
|
if filtered.is_empty() {
|
|
67
67
|
return String::new();
|
data/lib/inkmark/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: inkmark
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yaroslav Markin
|
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
202
202
|
- !ruby/object:Gem::Version
|
|
203
203
|
version: '0'
|
|
204
204
|
requirements: []
|
|
205
|
-
rubygems_version: 4.0.
|
|
205
|
+
rubygems_version: 4.0.20
|
|
206
206
|
specification_version: 4
|
|
207
207
|
summary: Very fast, feature-packed, AI-first Markdown gem for Ruby.
|
|
208
208
|
test_files: []
|