inkmark 0.1.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.
data/sig/inkmark.rbs ADDED
@@ -0,0 +1,219 @@
1
+ class Inkmark
2
+ VERSION: String
3
+
4
+ class Error < StandardError
5
+ end
6
+
7
+ class Options
8
+ type key = Symbol
9
+ type value = bool | String | Integer | Array[String] | Hash[Symbol, untyped] | nil
10
+ type defaults_hash = Hash[key, value]
11
+
12
+ # Nested element-policy hash types. Writers accept partial hashes
13
+ # (deep-merge semantics) so any subset of keys is valid on write;
14
+ # readers return the full hash with defaults filled in.
15
+ type headings_options = { attributes: bool, ids: bool }
16
+ type images_options = {
17
+ lazy: bool,
18
+ allowed_hosts: Array[String]?,
19
+ allowed_schemes: Array[String]?
20
+ }
21
+ type links_options = {
22
+ autolink: bool,
23
+ nofollow: bool,
24
+ allowed_hosts: Array[String]?,
25
+ allowed_schemes: Array[String]?
26
+ }
27
+
28
+ DEFAULTS: defaults_hash
29
+ PRESETS: Hash[Symbol, Hash[Symbol, untyped]]
30
+ DEFAULT_PRESET: Symbol
31
+ PRESETS_NATIVE_HASH: Hash[Symbol, Hash[Symbol, untyped]]
32
+
33
+ # +overrides+ accepts every option key, plus the pseudo-option
34
+ # +:preset+ (Symbol) which names a bundle from {PRESETS}.
35
+ def initialize: (?Hash[Symbol, untyped] overrides) -> void
36
+ def []: (key key) -> value
37
+ def []=: (key key, value value) -> value
38
+ def to_h: () -> defaults_hash
39
+ def to_native_hash: () -> Hash[Symbol, untyped]
40
+ def to_native_hash_frozen: () -> Hash[Symbol, untyped]
41
+ def merge: (defaults_hash | Inkmark::Options other) -> Inkmark::Options
42
+ def ==: (untyped other) -> bool
43
+ alias eql? ==
44
+ def initialize_copy: (Inkmark::Options orig) -> void
45
+
46
+ # Class-method fast path that skips allocating an Options instance.
47
+ # Marked +@api private+ in YARD; surfaced here because specs and
48
+ # the Inkmark class-method layer call it with an explicit receiver.
49
+ def self.native_hash_from: (Hash[Symbol, untyped] overrides) -> Hash[Symbol, untyped]
50
+
51
+ # Auto-generated accessors—one pair per DEFAULTS key.
52
+ def gfm: () -> bool
53
+ def gfm=: (bool) -> bool
54
+ def gfm_tag_filter: () -> bool
55
+ def gfm_tag_filter=: (bool) -> bool
56
+ def tables: () -> bool
57
+ def tables=: (bool) -> bool
58
+ def strikethrough: () -> bool
59
+ def strikethrough=: (bool) -> bool
60
+ def tasklists: () -> bool
61
+ def tasklists=: (bool) -> bool
62
+ def footnotes: () -> bool
63
+ def footnotes=: (bool) -> bool
64
+ def raw_html: () -> bool
65
+ def raw_html=: (bool) -> bool
66
+ def smart_punctuation: () -> bool
67
+ def smart_punctuation=: (bool) -> bool
68
+ # Readers return the full merged nested hash; writers accept and
69
+ # return the caller's *partial* hash (deep-merge semantics apply
70
+ # inside, so a partial input is legal and the Ruby +x = v+ form
71
+ # evaluates to +v+ as passed).
72
+ def headings: () -> headings_options
73
+ def headings=: (Hash[Symbol, untyped] value) -> Hash[Symbol, untyped]
74
+ def images: () -> images_options
75
+ def images=: (Hash[Symbol, untyped] value) -> Hash[Symbol, untyped]
76
+ def links: () -> links_options
77
+ def links=: (Hash[Symbol, untyped] value) -> Hash[Symbol, untyped]
78
+ def emoji_shortcodes: () -> bool
79
+ def emoji_shortcodes=: (bool) -> bool
80
+ def syntax_highlight: () -> bool
81
+ def syntax_highlight=: (bool) -> bool
82
+ def hard_wrap: () -> bool
83
+ def hard_wrap=: (bool) -> bool
84
+ def toc: () -> bool
85
+ def toc=: (bool | Hash[Symbol, untyped]) -> untyped
86
+ def statistics: () -> bool
87
+ def statistics=: (bool) -> bool
88
+ def extract: () -> Hash[Symbol, bool]?
89
+ def extract=: (Hash[Symbol, bool]?) -> Hash[Symbol, bool]?
90
+ def math: () -> bool
91
+ def math=: (bool) -> bool
92
+ def definition_list: () -> bool
93
+ def definition_list=: (bool) -> bool
94
+ def superscript: () -> bool
95
+ def superscript=: (bool) -> bool
96
+ def subscript: () -> bool
97
+ def subscript=: (bool) -> bool
98
+ def wikilinks: () -> bool
99
+ def wikilinks=: (bool) -> bool
100
+ def frontmatter: () -> bool
101
+ def frontmatter=: (bool) -> bool
102
+ end
103
+
104
+ # Rendered table of contents returned by {Inkmark#toc}. Immutable
105
+ # value object with value-equality over +markdown+ and +html+.
106
+ class Toc
107
+ attr_reader markdown: String
108
+ attr_reader html: String
109
+
110
+ def initialize: (markdown: String, html: String) -> void
111
+ def to_markdown: () -> String
112
+ def to_html: () -> String
113
+ def to_s: () -> String
114
+ def ==: (untyped other) -> bool
115
+ alias eql? ==
116
+ def hash: () -> Integer
117
+ end
118
+
119
+ # Events yielded to handlers registered via {Inkmark#on}.
120
+ class Event
121
+ attr_reader kind: Symbol
122
+ attr_reader text: String
123
+ attr_reader source: String?
124
+ attr_reader lang: String?
125
+ attr_reader byte_range: Range[Integer]?
126
+ attr_reader depth: Integer
127
+ attr_reader parent_kind: Symbol?
128
+ attr_reader ancestor_kinds: Array[Symbol]
129
+
130
+ attr_accessor dest: String?
131
+ attr_accessor title: String?
132
+ attr_accessor level: Integer?
133
+ attr_accessor id: String?
134
+ attr_accessor html: String?
135
+ attr_accessor markdown: String?
136
+
137
+ def initialize: (Hash[Symbol, untyped] data) -> void
138
+ def children: () -> Array[Event]
139
+ def children_of: (Symbol kind) -> Array[Event]
140
+ def delete: () -> void
141
+ def deleted?: () -> bool
142
+ end
143
+
144
+ type markdown_input = String | _ToS | nil
145
+ type options_input = Inkmark::Options | Hash[Symbol, untyped] | nil
146
+
147
+ # A chunk record returned by {chunks_by_heading}. Keys:
148
+ # heading (String?), level (Integer), id (String?),
149
+ # breadcrumb (Array[String]), content (String), and
150
+ # character_count / word_count (Integer) when statistics: true.
151
+ type chunk = Hash[Symbol, untyped]
152
+
153
+ # A window record returned by {chunks_by_size}. Keys:
154
+ # index (Integer), content (String), plus character_count /
155
+ # word_count (Integer) when statistics: true.
156
+ type window = Hash[Symbol, untyped]
157
+
158
+ # Truncation params accepted by {truncate_markdown} and by the
159
+ # {chunks_by_heading} +truncate:+ kwarg. At least one of
160
+ # +:chars+ / +:words+ must be set.
161
+ type truncate_params = {
162
+ chars: Integer?,
163
+ words: Integer?,
164
+ at: (:block | :word)?,
165
+ marker: String?
166
+ }
167
+
168
+ # Handler registry used by {#on} / {#walk} / {#to_html}.
169
+ type handlers = Hash[Symbol, Array[^(Inkmark::Event) -> void]]
170
+
171
+ # ── Class-method shortcuts ────────────────────────────────────────────
172
+ def self.to_html: (markdown_input source, ?options: options_input) -> String
173
+ def self.to_markdown: (markdown_input source, ?options: options_input) -> String
174
+ def self.to_plain_text: (markdown_input source, ?options: options_input) -> String
175
+ def self.chunks_by_heading: (markdown_input source, ?options: options_input, ?truncate: truncate_params?) -> Array[chunk]
176
+ def self.chunks_by_size: (markdown_input source, ?chars: Integer?, ?words: Integer?, ?overlap: Integer, ?at: (:block | :word), ?options: options_input) -> Array[window]
177
+ def self.truncate_markdown: (markdown_input source, ?chars: Integer?, ?words: Integer?, ?at: (:block | :word), ?marker: String?, ?options: options_input) -> String
178
+ def self.highlight_css: (?theme: String?) -> String
179
+ def self.highlight_themes: () -> Array[String]
180
+ def self.default_options: () -> Inkmark::Options
181
+ def self.default_options=: (options_input value) -> Inkmark::Options
182
+
183
+ # ── Native bindings (private in spirit; registered on the class) ──────
184
+ def self._native_to_html: (String source, Hash[Symbol, untyped]? opts_hash) -> String
185
+ def self._native_to_markdown: (String source, Hash[Symbol, untyped]? opts_hash) -> String
186
+ def self._native_to_plain_text: (String source, Hash[Symbol, untyped]? opts_hash) -> String
187
+ def self._native_chunks_by_heading: (String source, Hash[Symbol, untyped] opts_hash) -> Array[chunk]
188
+ def self._native_chunks_by_size: (String source, Hash[Symbol, untyped] opts_hash) -> Array[window]
189
+ def self._native_truncate_markdown: (String source, Hash[Symbol, untyped] params_hash, Hash[Symbol, untyped] opts_hash) -> String
190
+ def self._native_render_full: (String source, Hash[Symbol, untyped] opts_hash) -> Hash[Symbol, untyped]
191
+ def self._native_walk: (String source, Hash[Symbol, untyped] opts_hash, handlers handlers) -> void
192
+ def self._native_render_with_handlers: (String source, Hash[Symbol, untyped] opts_hash, handlers handlers) -> String
193
+ def self._syntax_css: (String? theme) -> String
194
+ def self._syntax_themes: () -> Array[String]
195
+
196
+ # ── Instance API ──────────────────────────────────────────────────────
197
+ attr_reader source: String
198
+ attr_reader options: Inkmark::Options
199
+
200
+ def initialize: (?markdown_input source, ?options: options_input) -> void
201
+ def source=: (markdown_input value) -> String
202
+ def options=: (options_input value) -> Inkmark::Options
203
+ def to_s: () -> String
204
+
205
+ def on: (Symbol kind) { (Inkmark::Event) -> void } -> self
206
+ def walk: () -> self
207
+
208
+ def to_html: () -> String
209
+ def to_markdown: () -> String
210
+ def to_plain_text: () -> String
211
+ def chunks_by_heading: (?truncate: truncate_params?) -> Array[chunk]
212
+ def chunks_by_size: (?chars: Integer?, ?words: Integer?, ?overlap: Integer, ?at: (:block | :word)) -> Array[window]
213
+ def truncate_markdown: (?chars: Integer?, ?words: Integer?, ?at: (:block | :word), ?marker: String?) -> String
214
+
215
+ def toc: () -> Inkmark::Toc?
216
+ def statistics: () -> Hash[Symbol, untyped]?
217
+ def extracts: () -> Hash[Symbol, Array[Hash[Symbol, untyped]]]?
218
+ def frontmatter: () -> Hash[String, untyped]?
219
+ end
metadata ADDED
@@ -0,0 +1,208 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inkmark
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yaroslav Markin
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rb_sys
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 0.9.126
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 0.9.126
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '13.0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '13.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: irb
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rbs
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '3.9'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '3.9'
68
+ - !ruby/object:Gem::Dependency
69
+ name: yard
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.9'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.9'
82
+ - !ruby/object:Gem::Dependency
83
+ name: standard
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: '1.3'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.3'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rspec
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '3.0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: lefthook
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 2.1.5
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 2.1.5
124
+ - !ruby/object:Gem::Dependency
125
+ name: rake-compiler
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ description: A very fast, feature-packed, AI-first markdown (CommonMark/GFM) gem for
139
+ Ruby, based on pulldown-cmark (Rust).
140
+ email:
141
+ - yaroslav@markin.net
142
+ executables: []
143
+ extensions:
144
+ - ext/inkmark/extconf.rb
145
+ extra_rdoc_files: []
146
+ files:
147
+ - CHANGELOG.md
148
+ - Cargo.lock
149
+ - Cargo.toml
150
+ - LICENSE.txt
151
+ - NOTICE
152
+ - README.md
153
+ - ext/inkmark/Cargo.toml
154
+ - ext/inkmark/build.rs
155
+ - ext/inkmark/extconf.rb
156
+ - ext/inkmark/src/autolink.rs
157
+ - ext/inkmark/src/chunks_by_heading.rs
158
+ - ext/inkmark/src/chunks_by_size.rs
159
+ - ext/inkmark/src/document.rs
160
+ - ext/inkmark/src/emoji.rs
161
+ - ext/inkmark/src/handler.rs
162
+ - ext/inkmark/src/heading.rs
163
+ - ext/inkmark/src/highlight.rs
164
+ - ext/inkmark/src/image.rs
165
+ - ext/inkmark/src/lib.rs
166
+ - ext/inkmark/src/link.rs
167
+ - ext/inkmark/src/options.rs
168
+ - ext/inkmark/src/plain_text.rs
169
+ - ext/inkmark/src/scheme_filter.rs
170
+ - ext/inkmark/src/stats.rs
171
+ - ext/inkmark/src/tag_filter.rs
172
+ - ext/inkmark/src/toc.rs
173
+ - ext/inkmark/src/truncate.rs
174
+ - ext/inkmark/src/url_match.rs
175
+ - lib/inkmark.rb
176
+ - lib/inkmark/event.rb
177
+ - lib/inkmark/native.rb
178
+ - lib/inkmark/options.rb
179
+ - lib/inkmark/toc.rb
180
+ - lib/inkmark/version.rb
181
+ - sig/inkmark.rbs
182
+ homepage: https://github.com/yaroslav/inkmark
183
+ licenses:
184
+ - MIT
185
+ metadata:
186
+ homepage_uri: https://github.com/yaroslav/inkmark
187
+ source_code_uri: https://github.com/yaroslav/inkmark
188
+ changelog_uri: https://github.com/yaroslav/inkmark/blob/main/CHANGELOG.md
189
+ bug_tracker_uri: https://github.com/yaroslav/inkmark/issues
190
+ documentation_uri: https://rubydoc.info/gems/inkmark
191
+ rdoc_options: []
192
+ require_paths:
193
+ - lib
194
+ required_ruby_version: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: 3.3.0
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ requirements: []
205
+ rubygems_version: 4.0.6
206
+ specification_version: 4
207
+ summary: Very fast, feature-packed, AI-first markdown gem for Ruby.
208
+ test_files: []