carve-lang 0.1.13 → 0.1.14

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: dd86e3f22259903b46f713f334ca0240f952a36b0b4031b2ee8feb14cd46ac12
4
- data.tar.gz: 4105bcf29dd8bc9f2f45e28f071fdd69aeefa68d9ead84f63c4e62a2f6ad453c
3
+ metadata.gz: 4dd61afa1f99ad2275ebb7f6cc544a01b707af0079fc29873efac9ef6dd0cef7
4
+ data.tar.gz: 4a69d2bf0ae5590dd8b022c15965bf9c3776a9c4b6ffb3e75813299f727815df
5
5
  SHA512:
6
- metadata.gz: 68d2513d78d2bbb00948dee60832a90ec0e4e16d47df0a3fd1385f675366aafc6db1c439948a269139ffd3acabdfffb09958476ee67a69e94f406353f7c49dba
7
- data.tar.gz: 82b8b597840cae9341c73498515ea587f4d8e6eb9df764a96db972f394e0c60c3cea02687df6dee67452e415ae1bbaff99c4985f5263bb06a2ee829592f2448e
6
+ metadata.gz: c4967a58da8dff2b74a5a248a3574788d4ebb8571c805b86a62595064627d2caf83b07d3e120af6bdccd85c20691b60f2f73565136d6226d6cd590a4a79bed0c
7
+ data.tar.gz: 678c47feec9d6c980fb349ca74ecc7d258f85120ec84b17938053a10c4c22ca152d7acc7daa0122cbb967434b59d2a04c46ebf22a12245ff7044ed967ade8283
data/CHANGELOG.md CHANGED
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.14] - 2026-11-12
11
+
12
+ The Ruby binding moves to the published carve-rs 0.1.14 engine and the 0.1.14 spec: one attach rule for `+`, comment lines erased before layout, braced table alignment, and a canonical writer that writes `***` and native `|=` headers.
13
+
14
+ ### Breaking
15
+
16
+ - Update to carve-rs 0.1.14. Block layout, `+` continuation markers, comment lines and lazy lines follow the 0.1.14 spec, so some documents parse differently (#237, #239, #253, #258).
17
+ - HTML import reads only `data-carve-*` roundtrip carriers; `data-djot-*` is no longer read. Lint configuration and suppression directives accept only `heading-level-skip`, not `a11y/heading-jump` (markup-carve/carve#5735).
18
+ - Lint reports a refused own-line `+` after a block as `refused-continuation-marker`; a refused first-block `+` keeps `continuation-marker-refused` (markup-carve/carve-rs#4201).
19
+ - `Carve.to_carve` writes every thematic break as `***` and table headers as native `|=` cells.
20
+
21
+ ### Improvements
22
+
23
+ - `Carve.decision_trace(source)` returns the block decision trace as JSON lines, and `Carve.lint(source, caption_hints: true)` turns on the opt-in caption hint (#244).
24
+ - Table cell alignment reads the braced form (`|={<}`, `|={~}`, `|={>}`); lint reports the 0.1.13 prefixes as `deprecated-cell-alignment`.
25
+
26
+ **Full Changelog**: https://github.com/markup-carve/carve-rb/compare/v0.1.13...v0.1.14
27
+
10
28
  ## [0.1.13] - 2026-10-25
11
29
 
12
30
  Task lists carry progress and blocked states through the Ruby binding. Rendering and import follow the 0.1.13 engine fixes.
data/README.md CHANGED
@@ -1,169 +1,26 @@
1
1
  # carve (Ruby)
2
2
 
3
- Native Ruby bindings for the
4
- [Carve](https://github.com/markup-carve/carve) markup language. The gem wraps
5
- the [carve-rs](https://github.com/markup-carve/carve-rs) engine through magnus
6
- and rb-sys rather than reimplementing the parser.
3
+ Ruby bindings for the Carve Rust engine. The gem processes Carve 0.1 documents through `carve-lang`. See the [Carve documentation](https://markup-carve.github.io/carve/).
7
4
 
8
5
  ## Install
9
6
 
10
- ```ruby
11
- gem "carve-lang"
12
- ```
13
-
14
- ```bash
15
- bundle install
16
- ```
17
-
18
- The distribution name is `carve-lang`, while the require path is `carve`.
19
-
20
- Releases after 0.1.9 ship precompiled gems for `x86_64-linux`,
21
- `x86_64-linux-musl`, `aarch64-linux`, `x86_64-darwin`, `arm64-darwin` and
22
- `x64-mingw-ucrt`, with a binary for each Ruby from 3.0 to 4.0 (from 3.1 on
23
- Windows, where Ruby 3.0 has no UCRT build). On those platforms `gem install`
24
- needs no Rust toolchain or libclang. Everywhere else, including newer Rubies,
25
- RubyGems installs the source gem and builds it as described below.
26
-
27
- ## Installing from source
28
-
29
- Version 0.1.9 and earlier ship source only, and so does every release on a
30
- platform or Ruby without a precompiled gem. There `gem install carve-lang`
31
- compiles a Rust extension on your machine, so the install needs:
32
-
33
- - A Rust toolchain with `cargo`, Rust 1.77 or newer. [rustup](https://rustup.rs)
34
- is the usual way to get one.
35
- - Ruby development headers (`ruby-dev` on Debian and Ubuntu).
36
- - libclang and clang. The build runs `bindgen` through `rb-sys` to read Ruby's
37
- C headers. On Debian and Ubuntu:
38
-
39
- ```bash
40
- sudo apt install libclang-dev clang
41
- ```
42
-
43
- If only libclang is installed, without the `clang` package, the build stops
44
- with this error:
45
-
46
- ```text
47
- /usr/include/ruby-3.2.0/ruby/ruby.h:23:10: fatal error: 'stdarg.h' file not found
48
- thread 'main' panicked at .../rb-sys-0.9.128/build/main.rs:52:6:
49
- generate bindings: ClangDiagnostic("/usr/include/ruby-3.2.0/ruby/ruby.h:23:10: fatal error: 'stdarg.h' file not found\n")
50
- error: failed to run custom build command for `rb-sys v0.9.128`
51
- ```
52
-
53
- libclang cannot find its own builtin headers. Install `clang`, or point
54
- bindgen at GCC's copy of those headers:
55
-
56
- ```bash
57
- BINDGEN_EXTRA_CLANG_ARGS="-I$(gcc -print-file-name=include)" gem install carve-lang
7
+ ```sh
8
+ gem install carve-lang
58
9
  ```
59
10
 
60
- With Bundler, export the variable before running `bundle install`.
61
-
62
- ## Render Carve
11
+ ## Usage
63
12
 
64
13
  ```ruby
65
14
  require "carve"
66
-
67
- Carve.to_html("# Hello *world*")
68
- Carve.to_markdown(source)
69
- Carve.to_plain_text(source)
70
- Carve.to_ansi(source)
71
- Carve.to_carve(source)
72
- Carve.to_carve(source, align_tables: true) # pad table columns
73
- ```
74
-
75
- Options configure extensions, safe rendering, profiles, symbols, section
76
- wrappers, and custom renderers:
77
-
78
- ```ruby
79
- Carve.to_html(
80
- source,
81
- extensions: %w[autolink list-table],
82
- safe: true,
83
- profile: "comment",
84
- )
15
+ puts Carve.to_html("# Hello *world*")
85
16
  ```
86
17
 
87
- `Carve::EXTENSIONS` reports the names accepted by the bundled engine. Unknown
88
- names raise `ArgumentError`.
89
-
90
- ## Errors
91
-
92
- An invalid argument raises `ArgumentError`, and a render the engine refuses -
93
- input past a profile's `max_length`, or a denied construct - also raises
94
- `ArgumentError` with the engine's reason.
95
-
96
- If the engine panics, the call raises `Carve::EnginePanic`, a `StandardError`
97
- subclass carrying the panic message and its location in the engine source. A
98
- panic means the engine reached a state it believed impossible, so the document
99
- is not renderable, but the process survives and a host can serve an error
100
- instead of losing the worker:
101
-
102
- ``` ruby
103
- begin
104
- Carve.to_html(untrusted_source)
105
- rescue Carve::EnginePanic => e
106
- logger.error("carve engine panic: #{e.message}")
107
- "<p>This document could not be rendered.</p>"
108
- end
109
- ```
110
-
111
- Report any input that raises it: a panic is an engine defect, not a rejection.
112
-
113
- ## Migration and AST access
114
-
115
- `Carve.from_html` and `Carve.from_markdown` return canonical Carve with
116
- structured fidelity reports. `Carve.parse` exposes a Ruby hash representation
117
- of the AST, and static rendering produces self-contained output for documents
118
- that do not load client-side renderers.
119
-
120
- The [usage reference](docs/reference.md) documents AST fields, static
121
- rendering, symbols, wrappers, profiles, and the main methods.
122
-
123
- ## Includes
124
-
125
- Includes are opt-in and require an absolute containment root plus the source
126
- document's absolute path:
127
-
128
- ```ruby
129
- result = Carve.to_html_with_includes(
130
- File.read("book.crv"),
131
- root: File.expand_path("."),
132
- source_path: File.expand_path("book.crv"),
133
- )
134
- ```
135
-
136
- The result contains the value, warnings, and root-relative dependencies. A
137
- warning from an included file names the chain of directives that reached it in
138
- `:includedBy`.
139
- Other render methods leave directives literal. See the
140
- [include reference](docs/reference.md#file-includes) for budgets, AST expansion,
141
- targets, and containment behavior.
142
-
143
- ## Lint
144
-
145
- `Carve.lint(source)` reports constructs that render but lose what the author
146
- wrote, such as an unattached attribute or a link to a missing id:
147
-
148
- ```ruby
149
- Carve.lint("é [x](#nope)\n").map { |f| [f[:rule], f[:line], f[:column]] }
150
- # => [["broken-fragment-link", 1, 3]]
151
- ```
152
-
153
- Columns and the `:start`/`:end` offsets count characters, not bytes. Pass
154
- `root:` and `source_path:` to lint included files too; each such finding names
155
- its file and the `:includedBy` chain. See the
156
- [lint reference](docs/reference.md#linting).
157
-
158
- ## Security
18
+ ## Documentation
159
19
 
160
- Use `safe: true` and a restrictive profile for untrusted documents. Custom
161
- renderer callbacks and symbol values are trusted output and may emit raw HTML.
162
- The [untrusted-input reference](docs/reference.md#untrusted-input) describes
163
- resource limits and URL handling.
20
+ - [Carve documentation](https://markup-carve.github.io/carve/)
21
+ - [Guide](docs/guide.md)
22
+ - [Documentation index](docs/README.md)
164
23
 
165
- ## Development
24
+ ## License
166
25
 
167
- Source builds, tests, and the carve-rs dependency pin are documented under
168
- [Development](docs/reference.md#develop) and
169
- [carve-rs dependency pin](docs/reference.md#carve-rs-dependency-pin).
26
+ [MIT](LICENSE).
data/ext/carve/Cargo.lock CHANGED
@@ -37,9 +37,9 @@ checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
37
37
 
38
38
  [[package]]
39
39
  name = "carve-lang"
40
- version = "0.1.13"
40
+ version = "0.1.14"
41
41
  source = "registry+https://github.com/rust-lang/crates.io-index"
42
- checksum = "9e6b4a7aaf0b516f73de750b0b4cb28dc1ecb12d4558d420f501dc27c52c9ba0"
42
+ checksum = "88eea74f39e1bd6187a0150d6d61d955cfc777b8871696966dbe3cafc29635f9"
43
43
  dependencies = [
44
44
  "html5ever",
45
45
  "markup5ever_rcdom",
@@ -54,7 +54,7 @@ dependencies = [
54
54
 
55
55
  [[package]]
56
56
  name = "carve-rb"
57
- version = "0.1.13"
57
+ version = "0.1.14"
58
58
  dependencies = [
59
59
  "carve-lang",
60
60
  "magnus",
data/ext/carve/Cargo.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "carve-rb"
3
- version = "0.1.13"
3
+ version = "0.1.14"
4
4
  edition = "2021"
5
5
  rust-version = "1.75"
6
6
  publish = false
@@ -22,4 +22,4 @@ serde_json = "1"
22
22
  # The Carve engine. Imported under the Rust crate alias `carve_rs` so the
23
23
  # binding's own crate name (`carve-rb`) does not collide with the engine's
24
24
  # package name (`carve`) in the Cargo lockfile.
25
- carve_rs = { package = "carve-lang", version = "=0.1.13" }
25
+ carve_rs = { package = "carve-lang", version = "=0.1.14" }
data/ext/carve/src/lib.rs CHANGED
@@ -227,6 +227,10 @@ fn to_ansi(source: String) -> String {
227
227
  }
228
228
 
229
229
  /// Canonical Carve source; a writer refusal returns the source as authored.
230
+ fn decision_trace(source: String) -> String {
231
+ carve_rs::decision_trace(&source)
232
+ }
233
+
230
234
  fn to_carve(source: String, align_tables: bool) -> String {
231
235
  let options = Options::default().with_align_tables(align_tables);
232
236
  carve_rs::try_to_carve_with_options(&source, &options).unwrap_or(source)
@@ -442,21 +446,25 @@ fn render_with_includes_json(
442
446
  )
443
447
  .map_err(|error| Error::new(ruby.exception_arg_error(), error.to_string()))?;
444
448
  let rendered = match which {
445
- IncludeTarget::Html => carve_rs::render_html_with_options(&prepared.doc, &render_options),
449
+ IncludeTarget::Html => carve_rs::render_html_with_options(&prepared.doc, &render_options)
450
+ .map_err(|error| error.to_string()),
446
451
  IncludeTarget::Markdown => {
447
452
  carve_rs::render_markdown_with_options(&prepared.doc, &render_options)
453
+ .map_err(|error| error.to_string())
448
454
  }
449
455
  IncludeTarget::Plain => {
450
456
  carve_rs::render_plain_text_with_options(&prepared.doc, &render_options)
457
+ .map_err(|error| error.to_string())
451
458
  }
452
- IncludeTarget::Ansi => carve_rs::render_ansi_with_options(&prepared.doc, &render_options),
459
+ IncludeTarget::Ansi => carve_rs::render_ansi_with_options(&prepared.doc, &render_options)
460
+ .map_err(|error| error.to_string()),
453
461
  // The AST is published as a tree, not as a string, so a caller does not
454
462
  // parse JSON twice. Positions stay OFF, unlike `to_ast_json`: spec I4
455
463
  // leaves position remapping out of scope in every engine, so a child's
456
464
  // spans would point into a document the caller never passed.
457
465
  IncludeTarget::Ast => Ok(ast_json_with_version(carve_rs::to_json(&prepared.doc))),
458
466
  }
459
- .map_err(|error| Error::new(ruby.exception_runtime_error(), error.to_string()))?;
467
+ .map_err(|error| Error::new(ruby.exception_runtime_error(), error))?;
460
468
  let value: serde_json::Value = if which == IncludeTarget::Ast {
461
469
  serde_json::from_str(&rendered).map_err(|error| {
462
470
  Error::new(
@@ -540,12 +548,14 @@ fn lint_json(
540
548
  max_bytes: Option<usize>,
541
549
  max_resolver_calls: Option<usize>,
542
550
  max_warnings: Option<usize>,
551
+ caption_hints: bool,
543
552
  ) -> Result<String, Error> {
544
553
  let boxed = boxed_extensions(ruby, names)?;
545
554
  let mut options = Options::new();
546
555
  for extension in &boxed {
547
556
  options = options.with_extension(extension.as_ref());
548
557
  }
558
+ options.lint_caption_looking_paragraph = caption_hints;
549
559
  // The document's own findings come first in `lint_carve_with_options`, and
550
560
  // they are the only ones whose offsets index `source`. Linting it alone
551
561
  // first tells the two apart without guessing from a finding's fields.
@@ -1079,6 +1089,7 @@ impl From<Source> for String {
1079
1089
 
1080
1090
  guarded!(g_to_html(source: Source) -> String => to_html);
1081
1091
  guarded!(g_to_markdown(source: Source) -> String => to_markdown);
1092
+ guarded!(g_decision_trace(source: Source) -> String => decision_trace);
1082
1093
  guarded!(g_to_plain_text(source: Source) -> String => to_plain_text);
1083
1094
  guarded!(g_to_ansi(source: Source) -> String => to_ansi);
1084
1095
  guarded!(g_to_carve(source: Source, align_tables: bool) -> String => to_carve);
@@ -1165,7 +1176,8 @@ guarded!(
1165
1176
  max_depth: Option<usize>,
1166
1177
  max_bytes: Option<usize>,
1167
1178
  max_resolver_calls: Option<usize>,
1168
- max_warnings: Option<usize>
1179
+ max_warnings: Option<usize>,
1180
+ caption_hints: bool
1169
1181
  ) -> String =>? lint_json
1170
1182
  );
1171
1183
 
@@ -1218,6 +1230,7 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
1218
1230
  module.define_singleton_method("_read_stamp", function!(g_read_stamp, 1))?;
1219
1231
  module.define_singleton_method("_stamp_needs_review", function!(g_stamp_needs_review, 2))?;
1220
1232
  module.define_singleton_method("_panic_probe", function!(g_panic_probe, 0))?;
1221
- module.define_singleton_method("_lint_json", function!(g_lint_json, 8))?;
1233
+ module.define_singleton_method("_lint_json", function!(g_lint_json, 9))?;
1234
+ module.define_singleton_method("decision_trace", function!(g_decision_trace, 1))?;
1222
1235
  Ok(())
1223
1236
  }
data/lib/carve/version.rb CHANGED
@@ -8,5 +8,5 @@ module Carve
8
8
  # compares it against ext/carve/Cargo.toml and against the newest cut
9
9
  # CHANGELOG section on every run, and .github/workflows/release.yml refuses to
10
10
  # publish a gem whose version is not the tag being released.
11
- VERSION = "0.1.13"
11
+ VERSION = "0.1.14"
12
12
  end
data/lib/carve.rb CHANGED
@@ -172,7 +172,9 @@ module Carve
172
172
  # The engine reports no severity: every finding is a warning.
173
173
  #
174
174
  # Pass the same +extensions:+ you render with, since they change which
175
- # constructs are elements and which rules apply.
175
+ # constructs are elements and which rules apply. +caption_hints: true+
176
+ # turns on the opt-in +caption-looking-paragraph+ hint for a paragraph
177
+ # beside an image or table that reads like a caption.
176
178
  #
177
179
  # ==== Following includes
178
180
  #
@@ -183,7 +185,7 @@ module Carve
183
185
  # top-level first, as +{file:, line:, column:}+. The budgets
184
186
  # (+max_depth:+ and the rest) mean what they mean for rendering.
185
187
  def lint(source, extensions: nil, root: nil, source_path: nil, max_depth: nil,
186
- max_bytes: nil, max_resolver_calls: nil, max_warnings: nil)
188
+ max_bytes: nil, max_resolver_calls: nil, max_warnings: nil, caption_hints: false)
187
189
  JSON.parse(
188
190
  _lint_json(
189
191
  source.to_s,
@@ -194,6 +196,7 @@ module Carve
194
196
  max_bytes,
195
197
  max_resolver_calls,
196
198
  max_warnings,
199
+ caption_hints ? true : false,
197
200
  ),
198
201
  symbolize_names: true,
199
202
  )
@@ -420,8 +423,8 @@ module Carve
420
423
  # Frontmatter is the first child, carrying +:format+ and RAW +:content+.
421
424
  #
422
425
  # Every node is a Hash with a +:type+ key plus its fields; child collections
423
- # are Arrays; +:attrs+ is +nil+ or a Hash of +{id:, classes:, key_values:}+.
424
- # Keys are symbols. This is the raw parse tree (default profile, no
426
+ # are Arrays; +:attrs+ is +nil+ or a Hash holding whichever of +:id+,
427
+ # +:classes+, +:keyValues+ and +:order+ the source wrote. Keys are symbols. This is the raw parse tree (default profile, no
425
428
  # extensions), suitable for a custom renderer (e.g. Carve -> PDF).
426
429
  def parse(source)
427
430
  # max_nesting: false - the engine already bounds nesting (its own
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carve-lang
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - markup-carve
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-25 00:00:00.000000000 Z
11
+ date: 2026-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys