jekyll-carve 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1d5439f1f1f23a853c560a40a84f7b210a2625682f4b5a66483cfb23361744f4
4
+ data.tar.gz: 87ae6478fa6a2af0e2026611f41fb4d2118677496222325d89e9f8cb03a7156e
5
+ SHA512:
6
+ metadata.gz: b5cd475edd480cd1465c4114b13ecd817c916342e0b073939cc773e3e09f85d8a294aa55b3ed6eb28b56889de1cce67e3a3c91a2716ff53f1a8d5d36935c40b0
7
+ data.tar.gz: 79a03d86ffe55a4c7fcd8c0f23d071ff6479745d241b4f216775d27eb4d122e91c2b1c76fca5228e877a9279dcd0152abf69339a83f6c62bee59a719e914851a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 markup-carve
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # jekyll-carve
2
+
3
+ A [Jekyll](https://jekyllrb.com) converter plugin for the
4
+ [Carve](https://github.com/markup-carve/carve) markup language. It renders
5
+ `.crv` pages to HTML by delegating to the native
6
+ [`carve-lang`](https://github.com/markup-carve/carve-rb) gem (`Carve.to_html`). No
7
+ parser is reimplemented here; this is a thin `Jekyll::Converter` adapter over
8
+ the engine.
9
+
10
+ ## Install
11
+
12
+ Add both gems to your site's `Gemfile`:
13
+
14
+ ```ruby
15
+ # Gemfile
16
+ gem "jekyll-carve"
17
+ gem "carve-lang" # the native Carve engine (a runtime dependency, listed for clarity)
18
+ ```
19
+
20
+ ```sh
21
+ bundle install
22
+ ```
23
+
24
+ Then enable the plugin in `_config.yml`:
25
+
26
+ ```yaml
27
+ plugins:
28
+ - jekyll-carve
29
+ ```
30
+
31
+ > [!NOTE]
32
+ > The `carve-lang` gem ships a Rust native extension and is compiled at install
33
+ > time. It requires a Rust toolchain (`cargo`) and Ruby development headers.
34
+ > See the carve-rb README for build notes (including the libclang/`stdarg.h`
35
+ > workaround on some systems).
36
+
37
+ ## Configuration
38
+
39
+ Carve engine options are read from `_config.yml` under the `carve` key:
40
+
41
+ ```yaml
42
+ carve:
43
+ extensions:
44
+ - heading_permalinks
45
+ - math_block
46
+ - autolink
47
+ ```
48
+
49
+ `carve.extensions` is an array of opt-in Carve extension names (Strings or
50
+ hyphenated/underscored forms, passed straight through to the engine). When the
51
+ key is absent, no extensions are enabled. The recognized extensions are listed
52
+ in `Carve::EXTENSIONS`; an unknown name raises `ArgumentError` at build time.
53
+
54
+ ## Usage
55
+
56
+ Create a page with a `.crv` extension. It MUST begin with Jekyll
57
+ YAML front matter, and the Carve body follows below:
58
+
59
+ ```text
60
+ ---
61
+ layout: default
62
+ title: Home
63
+ ---
64
+ # Welcome to *Carve*
65
+
66
+ This is /italic/ and *bold* text.
67
+
68
+ - Apple
69
+ - Banana
70
+ ```
71
+
72
+ Note Carve's inline syntax: `*...*` is **strong** (bold) and `/.../` is
73
+ _emphasis_ (italic) - the opposite of Markdown.
74
+
75
+ ## Important: Jekyll front matter vs. Carve frontmatter
76
+
77
+ This is the one nuance to understand:
78
+
79
+ - **Jekyll only runs a file through a converter if it has YAML front matter**
80
+ (a `---` ... `---` block at the very top). A `.crv` file with no front
81
+ matter is treated as a static file and copied verbatim, NOT converted.
82
+ - **Jekyll strips that front matter before calling the converter.** So the
83
+ converter (and therefore the Carve engine) receives only the document
84
+ **body**, never the Jekyll front matter.
85
+ - **Carve itself also uses `---` for its own frontmatter.** In a Jekyll site
86
+ the Jekyll front matter wins: the top `---` ... `---` block is consumed by
87
+ Jekyll, and whatever remains is handed to Carve as the body.
88
+
89
+ Practical rule: a `.crv` page in Jekyll needs at least an empty front matter
90
+ block so Jekyll processes it:
91
+
92
+ ```text
93
+ ---
94
+ ---
95
+ # Your Carve content here
96
+ ```
97
+
98
+ Put page metadata (`title`, `layout`, etc.) in the Jekyll front matter. Do not
99
+ add a second Carve `---` frontmatter block expecting Carve to parse it; Jekyll
100
+ has already removed the leading block by the time Carve runs.
101
+
102
+ ## Converter API
103
+
104
+ `Jekyll::Carve::Converter < Jekyll::Converter`:
105
+
106
+ | Method | Behavior |
107
+ | ------ | -------- |
108
+ | `matches(ext)` | `true` for `.crv` (with or without the leading dot, case-insensitive), `false` otherwise. |
109
+ | `output_ext(ext)` | `".html"` (includes the dot so Jekyll emits `page.html`). |
110
+ | `convert(content)` | `Carve.to_html(content, extensions: configured)` - the rendered HTML. |
111
+ | `carve_extensions` | The extension list read from `carve.extensions` in `_config.yml` (empty by default). |
112
+
113
+ ## Development
114
+
115
+ ```sh
116
+ bundle install
117
+ rspec # run the converter unit tests
118
+ ```
119
+
120
+ ## License
121
+
122
+ MIT, markup-carve.
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Carve
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "jekyll"
4
+ require "carve"
5
+
6
+ require "jekyll/carve/version"
7
+
8
+ module Jekyll
9
+ module Carve
10
+ # Jekyll converter for the Carve markup language.
11
+ #
12
+ # Registers the `.crv` file extension and renders Carve
13
+ # bodies to HTML by delegating to the native `carve-lang` gem
14
+ # (Carve.to_html). No parsing is reimplemented here; this is a thin
15
+ # Jekyll::Converter adapter over the engine.
16
+ class Converter < Jekyll::Converter
17
+ # File extensions this converter handles (lowercased, with and without
18
+ # the leading dot so callers may pass either form).
19
+ EXTENSIONS = %w[.crv].freeze
20
+
21
+ safe true
22
+ priority :low
23
+
24
+ # Does the given file extension belong to Carve?
25
+ #
26
+ # Accepts both ".crv" and "crv" (Jekyll passes the dotted form).
27
+ #
28
+ # ext - The String extension to check.
29
+ #
30
+ # Returns true if it matches, false otherwise.
31
+ def matches(ext)
32
+ return false if ext.nil?
33
+
34
+ normalized = ext.to_s.downcase
35
+ normalized = ".#{normalized}" unless normalized.start_with?(".")
36
+ EXTENSIONS.include?(normalized)
37
+ end
38
+
39
+ # The output extension for a converted Carve file.
40
+ #
41
+ # Jekyll appends this string directly to the output path
42
+ # (":basename:output_ext"), so it MUST include the leading dot to
43
+ # produce "index.html" rather than "indexhtml". This matches Jekyll's
44
+ # own Markdown converter, which returns ".html".
45
+ #
46
+ # Returns ".html".
47
+ def output_ext(_ext)
48
+ ".html"
49
+ end
50
+
51
+ # Convert a Carve document body to HTML.
52
+ #
53
+ # Jekyll strips the YAML front matter before calling this, so `content`
54
+ # is the Carve body only.
55
+ #
56
+ # content - String body of the source file (front matter removed).
57
+ #
58
+ # Returns the rendered HTML String.
59
+ def convert(content)
60
+ ::Carve.to_html(content.to_s, extensions: carve_extensions)
61
+ end
62
+
63
+ # Carve extensions configured under `carve.extensions` in _config.yml.
64
+ #
65
+ # Returns an Array of extension names (Strings/Symbols passed through to
66
+ # the engine). Empty when nothing is configured.
67
+ def carve_extensions
68
+ carve_config = @config.is_a?(Hash) ? @config["carve"] : nil
69
+ return [] unless carve_config.is_a?(Hash)
70
+
71
+ Array(carve_config["extensions"])
72
+ end
73
+ end
74
+ end
75
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-carve
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - markup-carve
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-08-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: carve-lang
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.1.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.1.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: jekyll
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description: |-
56
+ A Jekyll plugin that renders Carve (.crv) pages to HTML. It is a
57
+ thin Jekyll::Converter over the native `carve-lang` gem (Carve.to_html);
58
+ no parser is reimplemented.
59
+ email:
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - LICENSE
65
+ - README.md
66
+ - lib/jekyll-carve.rb
67
+ - lib/jekyll/carve/version.rb
68
+ homepage: https://github.com/markup-carve/jekyll-carve
69
+ licenses:
70
+ - MIT
71
+ metadata: {}
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 3.0.0
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ requirements: []
87
+ rubygems_version: 3.4.19
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Jekyll converter for the Carve markup language.
91
+ test_files: []