jekyll-carve 0.1.4 → 0.2.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 +4 -4
- data/README.md +9 -287
- data/lib/jekyll/carve/version.rb +1 -1
- data/lib/jekyll-carve.rb +137 -25
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2cde304fead318a3fa4f0103c4e924c57497431e82df659d148e3920a269fe3f
|
|
4
|
+
data.tar.gz: cf27d90fb4ce5f682b0c1f4f187712dc097191f0dcc6edf658eaabff59c6551b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eaa676d413474872abec7eae9e8a0f4100c8e74a104aaa225242562e21d8f0cd9b6d35eb2e2ac23a68467e7964926a35c4f076b2afd81f2f24930222d3eb31ee
|
|
7
|
+
data.tar.gz: 710ddf6fc538f98f53b3a5a238cf40077f56be7546383961e04f7e4b3a4b6e60c9dc4fb94a783e3b73f956a4794c9ee211ef3598e5b11d99fb7a5f4107b99028
|
data/README.md
CHANGED
|
@@ -1,303 +1,25 @@
|
|
|
1
1
|
# jekyll-carve
|
|
2
2
|
|
|
3
|
-
|
|
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.
|
|
3
|
+
Jekyll converter for `.crv` pages, using the Carve 0.2 engine. It renders Carve pages through the native engine. Read the [Carve documentation](https://markup-carve.github.io/carve/) for the language syntax.
|
|
9
4
|
|
|
10
5
|
## Install
|
|
11
6
|
|
|
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
7
|
```sh
|
|
21
|
-
bundle
|
|
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
|
-
### `carve.symbols` - what `:smile:` renders as
|
|
55
|
-
|
|
56
|
-
Carve parses `:name:` in core, no extension needed, but what a name renders as
|
|
57
|
-
is a render option. With no map configured a shortcode renders as its own
|
|
58
|
-
source text:
|
|
59
|
-
|
|
60
|
-
```text
|
|
61
|
-
Ship it :smile:
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
```html
|
|
65
|
-
<p>Ship it :smile:</p>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
`carve.symbols` supplies the map. It takes a mapping written inline:
|
|
69
|
-
|
|
70
|
-
```yaml
|
|
71
|
-
carve:
|
|
72
|
-
symbols:
|
|
73
|
-
smile: "😄"
|
|
74
|
-
ship: "🚀"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
or a path to a JSON object, so a large map does not have to live in
|
|
78
|
-
`_config.yml`:
|
|
79
|
-
|
|
80
|
-
```yaml
|
|
81
|
-
carve:
|
|
82
|
-
symbols: _data/symbols.json
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
```json
|
|
86
|
-
{
|
|
87
|
-
"smile": "😄",
|
|
88
|
-
"ship": "🚀"
|
|
89
|
-
}
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
or a list mixing both, merged left to right, so a generated map can carry a few
|
|
93
|
-
site-specific overrides:
|
|
94
|
-
|
|
95
|
-
```yaml
|
|
96
|
-
carve:
|
|
97
|
-
symbols:
|
|
98
|
-
- _data/emoji.json
|
|
99
|
-
- ship: "🚀"
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
A path is resolved against the site source and confined to it, symlinks
|
|
103
|
-
included - a link inside the source pointing at a file outside it is refused
|
|
104
|
-
rather than followed. A name that
|
|
105
|
-
is not in the map keeps rendering as its own text, and the map does not loosen
|
|
106
|
-
Carve's word-boundary rule: `10:30:` and `a:smile:b` are not shortcodes, and
|
|
107
|
-
`` `:smile:` `` inside a code span stays code.
|
|
108
|
-
|
|
109
|
-
No emoji table ships with this plugin. Jekyll has no emoji database in core, so
|
|
110
|
-
bundling one here would be a second source of truth next to whatever your
|
|
111
|
-
Markdown pages already use (`jemoji`, for instance) - and the two would drift.
|
|
112
|
-
Point `carve.symbols` at a JSON file you generate from that same source and
|
|
113
|
-
both page types resolve one map.
|
|
114
|
-
|
|
115
|
-
A misconfigured map fails the build rather than being warned past: a missing
|
|
116
|
-
file, invalid JSON, a JSON top level that is not an object, or a value that is
|
|
117
|
-
not a string each raise `ArgumentError` naming the file or the key. A value is
|
|
118
|
-
not coerced, because it reaches the page raw - `count: 1` is a mistake worth
|
|
119
|
-
stopping for, not something to stringify and emit. A NAME is coerced, since
|
|
120
|
-
YAML hands back a Symbol or a boolean for some unquoted keys and a name never
|
|
121
|
-
reaches the output.
|
|
122
|
-
|
|
123
|
-
> [!WARNING]
|
|
124
|
-
> A symbol value is inserted as **trusted raw output**. It is not escaped, so
|
|
125
|
-
> `smile: "<img src='/s.svg'>"` emits a real `<img>` element rather than
|
|
126
|
-
> escaped text. This is deliberate in the engine - `carve-lang` documents it as
|
|
127
|
-
> "NEVER build a symbols map out of untrusted / user-supplied input" - and it
|
|
128
|
-
> is why this plugin reads the map only from `_config.yml` and from files at
|
|
129
|
-
> paths named there. Never generate `carve.symbols` from page content, from
|
|
130
|
-
> front matter, from a comment system, or from anything else a visitor can
|
|
131
|
-
> influence.
|
|
132
|
-
|
|
133
|
-
### `carve.includes` - pulling one file into another
|
|
134
|
-
|
|
135
|
-
A Carve page can pull another file in with `{{ path }}`. It stays literal until
|
|
136
|
-
the site asks:
|
|
137
|
-
|
|
138
|
-
```yaml
|
|
139
|
-
carve:
|
|
140
|
-
includes: true
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Includes need carve-lang 0.1.4 or later. On an older engine, a page that
|
|
144
|
-
reaches them stops the build with a message naming the upgrade.
|
|
145
|
-
|
|
146
|
-
Paths resolve relative to the file that wrote them, and nothing resolves outside
|
|
147
|
-
the containment root. The root is Jekyll's source directory unless
|
|
148
|
-
`carve.include_root` names another one, and an include that would leave it is
|
|
149
|
-
not expanded.
|
|
150
|
-
|
|
151
|
-
```yaml
|
|
152
|
-
carve:
|
|
153
|
-
includes: true
|
|
154
|
-
include_root: /srv/shared/fragments
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`carve.include_root` must be an **absolute** path. A relative one is refused
|
|
158
|
-
rather than resolved, because resolving it lands on whatever directory the build
|
|
159
|
-
ran from, which is not a root anyone chose. The page being rendered has to sit
|
|
160
|
-
inside the root too.
|
|
161
|
-
|
|
162
|
-
A target that cannot be read is reported against the page that asked for it, and
|
|
163
|
-
the directive is left as written. The message does not say whether the file was
|
|
164
|
-
missing or refused by containment: both report `include-unresolved`, so a page
|
|
165
|
-
cannot be used to probe the filesystem. The class is at `--verbose`.
|
|
166
|
-
|
|
167
|
-
Under `jekyll serve`, a page is rebuilt when a target it read changes, because
|
|
168
|
-
every resolved target is registered with Jekyll's regeneration path.
|
|
169
|
-
|
|
170
|
-
A conversion with no page behind it - the converter called directly on a String -
|
|
171
|
-
leaves the directive literal, since there is no file for a relative path to
|
|
172
|
-
resolve against.
|
|
173
|
-
|
|
174
|
-
> [!NOTE]
|
|
175
|
-
> Fragments under the source directory are pages in their own right, so Jekyll
|
|
176
|
-
> will publish them. Exclude them in `_config.yml`, or keep them outside the
|
|
177
|
-
> source and point `include_root` at the tree above both.
|
|
178
|
-
|
|
179
|
-
### `carve.lint` - reporting what renders but is lost
|
|
180
|
-
|
|
181
|
-
Carve's linter reports constructs that parse and render, but not the way the
|
|
182
|
-
author meant: a block attribute that attaches to nothing, a link to an id no
|
|
183
|
-
heading has, an unclosed code fence. Turn it on to see them as build warnings:
|
|
184
|
-
|
|
185
|
-
```yaml
|
|
186
|
-
carve:
|
|
187
|
-
lint: true
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
```
|
|
191
|
-
Carve lint: guide/intro.crv:7:1: unattached-block-attribute: This block attribute reaches no block: ...
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
Each warning names the page, the line and column in the file, and the rule id.
|
|
195
|
-
The line counts the front matter, so it matches your editor; a Liquid tag that
|
|
196
|
-
expands to several lines shifts the lines below it, since the linter reads the
|
|
197
|
-
page after Liquid. Pages still render.
|
|
198
|
-
|
|
199
|
-
To fail the build instead, use `strict`:
|
|
200
|
-
|
|
201
|
-
```yaml
|
|
202
|
-
carve:
|
|
203
|
-
lint: strict
|
|
8
|
+
bundle add jekyll-carve
|
|
204
9
|
```
|
|
205
10
|
|
|
206
|
-
Every page is linted and reported first, then `jekyll build` stops with an
|
|
207
|
-
error before writing the site.
|
|
208
|
-
|
|
209
|
-
The linter reads the same `carve.extensions` the pages render with. With
|
|
210
|
-
`carve.includes` on it also lints each included Carve file, and a finding there
|
|
211
|
-
names that file: `index.crv (parts/intro.crv:3:1): ...`. Include warnings such
|
|
212
|
-
as `include-unresolved` are logged once, by the include pass, but count toward
|
|
213
|
-
`strict`.
|
|
214
|
-
|
|
215
|
-
`carve.lint` needs carve-lang 0.1.11 or later, the first engine that exposes the
|
|
216
|
-
linter. That is why it is this gem's floor.
|
|
217
|
-
|
|
218
11
|
## Usage
|
|
219
12
|
|
|
220
|
-
Create a page with a `.crv` extension. It MUST begin with Jekyll
|
|
221
|
-
YAML front matter, and the Carve body follows below:
|
|
222
|
-
|
|
223
|
-
```text
|
|
224
|
-
---
|
|
225
|
-
layout: default
|
|
226
|
-
title: Home
|
|
227
|
-
---
|
|
228
|
-
# Welcome to *Carve*
|
|
229
|
-
|
|
230
|
-
This is /italic/ and *bold* text.
|
|
231
|
-
|
|
232
|
-
- Apple
|
|
233
|
-
- Banana
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
Note Carve's inline syntax: `*...*` is **strong** (bold) and `/.../` is
|
|
237
|
-
_emphasis_ (italic) - the opposite of Markdown.
|
|
238
|
-
|
|
239
|
-
## Highlighting Carve code blocks
|
|
240
|
-
|
|
241
|
-
This plugin renders `.crv` pages. To highlight a ` ```carve ` block inside a
|
|
242
|
-
Markdown page, add [rouge-carve](https://github.com/markup-carve/rouge-carve),
|
|
243
|
-
which registers a Carve lexer with Rouge, Jekyll's default highlighter:
|
|
244
|
-
|
|
245
|
-
```ruby
|
|
246
|
-
# Gemfile
|
|
247
|
-
group :jekyll_plugins do
|
|
248
|
-
gem "rouge-carve"
|
|
249
|
-
end
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Jekyll requires every gem in the `jekyll_plugins` group on its own. Without
|
|
253
|
-
that group, list it in `_config.yml` instead:
|
|
254
|
-
|
|
255
13
|
```yaml
|
|
256
|
-
plugins:
|
|
257
|
-
- jekyll-carve
|
|
258
|
-
- rouge-carve
|
|
14
|
+
plugins: [jekyll-carve]
|
|
259
15
|
```
|
|
260
16
|
|
|
261
|
-
##
|
|
262
|
-
|
|
263
|
-
This is the one nuance to understand:
|
|
264
|
-
|
|
265
|
-
- **Jekyll only runs a file through a converter if it has YAML front matter**
|
|
266
|
-
(a `---` ... `---` block at the very top). A `.crv` file with no front
|
|
267
|
-
matter is treated as a static file and copied verbatim, NOT converted.
|
|
268
|
-
- **Jekyll strips that front matter before calling the converter.** So the
|
|
269
|
-
converter (and therefore the Carve engine) receives only the document
|
|
270
|
-
**body**, never the Jekyll front matter.
|
|
271
|
-
- **Carve itself also uses `---` for its own frontmatter.** In a Jekyll site
|
|
272
|
-
the Jekyll front matter wins: the top `---` ... `---` block is consumed by
|
|
273
|
-
Jekyll, and whatever remains is handed to Carve as the body.
|
|
274
|
-
|
|
275
|
-
Practical rule: a `.crv` page in Jekyll needs at least an empty front matter
|
|
276
|
-
block so Jekyll processes it:
|
|
277
|
-
|
|
278
|
-
```text
|
|
279
|
-
---
|
|
280
|
-
---
|
|
281
|
-
# Your Carve content here
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
Put page metadata (`title`, `layout`, etc.) in the Jekyll front matter. Do not
|
|
285
|
-
add a second Carve `---` frontmatter block expecting Carve to parse it; Jekyll
|
|
286
|
-
has already removed the leading block by the time Carve runs.
|
|
287
|
-
|
|
288
|
-
## Converter API
|
|
289
|
-
|
|
290
|
-
`Jekyll::Carve::Converter < Jekyll::Converter`:
|
|
17
|
+
## Documentation
|
|
291
18
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
| `output_ext(ext)` | `".html"` (includes the dot so Jekyll emits `page.html`). |
|
|
296
|
-
| `convert(content)` | `Carve.to_html(content, extensions: configured, symbols: configured)` - the rendered HTML. |
|
|
297
|
-
| `carve_extensions` | The extension list read from `carve.extensions` in `_config.yml` (empty by default). |
|
|
298
|
-
| `carve_symbols` | The `:name:` map read from `carve.symbols` in `_config.yml`, or `nil` when the key is absent. Resolved once per build. |
|
|
299
|
-
| `reset_symbols` | Drops the cached map. Called from the `site, after_reset` hook this plugin registers, which is what scopes the cache to a build so `jekyll serve --watch` picks up an edit to a symbol file. |
|
|
19
|
+
- [Carve documentation](https://markup-carve.github.io/carve/)
|
|
20
|
+
- [Documentation index](docs/README.md)
|
|
21
|
+
- [Development](docs/development.md)
|
|
300
22
|
|
|
301
|
-
##
|
|
23
|
+
## License
|
|
302
24
|
|
|
303
|
-
|
|
25
|
+
[MIT](LICENSE)
|
data/lib/jekyll/carve/version.rb
CHANGED
data/lib/jekyll-carve.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "json"
|
|
4
|
+
require "pathname"
|
|
4
5
|
|
|
5
6
|
require "jekyll"
|
|
6
7
|
require "carve"
|
|
@@ -59,6 +60,7 @@ module Jekyll
|
|
|
59
60
|
#
|
|
60
61
|
# Returns the rendered HTML String.
|
|
61
62
|
def convert(content)
|
|
63
|
+
require_carve_02!
|
|
62
64
|
document = Rendering.current
|
|
63
65
|
root = include_root
|
|
64
66
|
include_page = !(root.nil? || document.nil? || document.path.to_s.empty?)
|
|
@@ -184,27 +186,127 @@ module Jekyll
|
|
|
184
186
|
remove_instance_variable(:@symbols) if defined?(@symbols)
|
|
185
187
|
end
|
|
186
188
|
|
|
189
|
+
# `carve.raw_html: true` emits `=html` blocks and spans verbatim. Carve
|
|
190
|
+
# 0.2 escapes them by default.
|
|
191
|
+
def raw_html?
|
|
192
|
+
carve_config["raw_html"] == true
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# `carve.heading_shift` moves every heading down by 0 to 5 levels.
|
|
196
|
+
def heading_shift
|
|
197
|
+
value = carve_config.fetch("heading_shift", 0)
|
|
198
|
+
return value if value.is_a?(Integer) && value.between?(0, 5)
|
|
199
|
+
|
|
200
|
+
raise ArgumentError, "carve.heading_shift: expected a number from 0 to 5, got #{value.inspect}"
|
|
201
|
+
end
|
|
202
|
+
|
|
187
203
|
private
|
|
188
204
|
|
|
205
|
+
# Check the 0.2 API as well as the declared dependency range.
|
|
206
|
+
def require_carve_02!
|
|
207
|
+
return if ::Carve.respond_to?(:call)
|
|
208
|
+
|
|
209
|
+
raise ArgumentError,
|
|
210
|
+
"jekyll-carve needs the Carve 0.2 carve-lang; " \
|
|
211
|
+
"the installed carve-lang #{::Carve::VERSION} is a 0.1 engine"
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# The Carve 0.2 standard extensions each 0.1 extension name stands for. A
|
|
215
|
+
# name missing here and not starting with `carve.` reaches the engine as
|
|
216
|
+
# written.
|
|
217
|
+
LEGACY_EXTENSIONS = {
|
|
218
|
+
"autolink" => ["carve.autolink"],
|
|
219
|
+
"citations" => ["carve.references"],
|
|
220
|
+
"code-callouts" => ["carve.codeCallouts"],
|
|
221
|
+
"code-group" => ["carve.codeGroup"],
|
|
222
|
+
"color-swatch" => ["carve.colorSwatch"],
|
|
223
|
+
"details" => ["carve.details"],
|
|
224
|
+
"external-links" => ["carve.externalLinks"],
|
|
225
|
+
"fenced-render" => ["carve.fencedRender.mermaid"],
|
|
226
|
+
"fenced-render-abc" => ["carve.fencedRender.abc"],
|
|
227
|
+
"fenced-render-chart" => ["carve.fencedRender.chart"],
|
|
228
|
+
"fenced-render-d2" => ["carve.fencedRender.d2"],
|
|
229
|
+
"fenced-render-graphviz" => ["carve.fencedRender.graphviz", "carve.fencedRender.dot"],
|
|
230
|
+
"fenced-render-plantuml" => ["carve.fencedRender.plantuml", "carve.fencedRender.puml"],
|
|
231
|
+
"fenced-render-vega-lite" => ["carve.fencedRender.vega-lite"],
|
|
232
|
+
"fenced-render-wavedrom" => ["carve.fencedRender.wavedrom"],
|
|
233
|
+
"glossary" => ["carve.glossary"],
|
|
234
|
+
"heading-numbers" => ["carve.headingNumbers"],
|
|
235
|
+
"heading-permalinks" => ["carve.headingPermalinks"],
|
|
236
|
+
"heading-reference" => ["carve.headingReference"],
|
|
237
|
+
"img-fence" => ["carve.imgFence.img", "carve.imgFence.image"],
|
|
238
|
+
"index" => ["carve.index"],
|
|
239
|
+
"link-policy" => ["carve.linkPolicy"],
|
|
240
|
+
"list-table" => ["carve.listTable"],
|
|
241
|
+
"math-block" => ["carve.mathBlock"],
|
|
242
|
+
"semantic-span" => ["carve.semanticSpan"],
|
|
243
|
+
"smart-quotes" => ["carve.smartQuotes"],
|
|
244
|
+
"spoiler" => ["carve.spoiler", "carve.spoilerBlock"],
|
|
245
|
+
"tab-normalize" => ["carve.tabNormalize"],
|
|
246
|
+
"table-of-contents" => ["carve.toc"],
|
|
247
|
+
"tabs" => ["carve.tabs"],
|
|
248
|
+
"toc" => ["carve.tocPlacement"],
|
|
249
|
+
"wikilinks" => ["carve.wiki"],
|
|
250
|
+
}.freeze
|
|
251
|
+
|
|
252
|
+
# Carve 0.2 replaced this extension with the render option `headingShift`.
|
|
253
|
+
REMOVED_HEADING_SHIFT = %w[heading-level-shift carve.headingLevelShift].freeze
|
|
254
|
+
|
|
255
|
+
# Standard extensions without a standard renderer in the engine.
|
|
256
|
+
NO_STANDARD_RENDERER = %w[carve.cite].freeze
|
|
257
|
+
|
|
258
|
+
# The 0.2 standard extension names for `carve.extensions`, or nil when the
|
|
259
|
+
# site configured none. 0.1 names are accepted in either spelling.
|
|
260
|
+
def engine_extensions
|
|
261
|
+
names = carve_extensions.flat_map do |entry|
|
|
262
|
+
name = entry.to_s
|
|
263
|
+
if REMOVED_HEADING_SHIFT.include?(name.tr("_", "-"))
|
|
264
|
+
raise ArgumentError,
|
|
265
|
+
"carve.extensions: #{name} is no extension in Carve 0.2; set carve.heading_shift: 1 instead"
|
|
266
|
+
end
|
|
267
|
+
next [name] if name.start_with?("carve.")
|
|
268
|
+
LEGACY_EXTENSIONS.fetch(name.tr("_", "-"), [name])
|
|
269
|
+
end.uniq
|
|
270
|
+
names.empty? ? nil : names
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
# The standard renderer for each enabled extension that has one.
|
|
274
|
+
def engine_renderers(names)
|
|
275
|
+
return nil if names.nil?
|
|
276
|
+
|
|
277
|
+
names.reject { |name| NO_STANDARD_RENDERER.include?(name) }.to_h { |name| [name, "standard"] }
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
def shift_option
|
|
281
|
+
shift = heading_shift
|
|
282
|
+
shift.zero? ? {} : { heading_shift: shift }
|
|
283
|
+
end
|
|
284
|
+
|
|
189
285
|
def render(content, document, root)
|
|
286
|
+
extensions = engine_extensions
|
|
287
|
+
shift = shift_option
|
|
190
288
|
if root.nil?
|
|
191
289
|
return ::Carve.to_html(content,
|
|
192
|
-
extensions:
|
|
193
|
-
|
|
290
|
+
extensions: extensions,
|
|
291
|
+
renderers: engine_renderers(extensions),
|
|
292
|
+
symbols: carve_symbols,
|
|
293
|
+
raw_html: raw_html?,
|
|
294
|
+
**shift)
|
|
194
295
|
end
|
|
195
|
-
|
|
296
|
+
|
|
196
297
|
unless ::Carve.respond_to?(:to_html_with_includes)
|
|
197
|
-
raise ArgumentError,
|
|
198
|
-
"carve.includes: the installed carve-lang (#{::Carve::VERSION}) has no " \
|
|
199
|
-
"to_html_with_includes; upgrade it to 0.1.4 or later, or set carve.includes: false"
|
|
298
|
+
raise ArgumentError, "carve.includes: the installed carve-lang is too old; upgrade it to 0.1.4 or later"
|
|
200
299
|
end
|
|
201
300
|
|
|
202
301
|
begin
|
|
203
302
|
result = ::Carve.to_html_with_includes(content,
|
|
204
303
|
root: root,
|
|
205
304
|
source_path: document.path,
|
|
206
|
-
extensions:
|
|
207
|
-
|
|
305
|
+
extensions: extensions,
|
|
306
|
+
renderers: engine_renderers(extensions),
|
|
307
|
+
symbols: carve_symbols,
|
|
308
|
+
raw_html: raw_html?,
|
|
309
|
+
**shift)
|
|
208
310
|
rescue ArgumentError => e
|
|
209
311
|
# A relative root, or a page outside it. Both are decided by the
|
|
210
312
|
# engine; what this adds is the key and the page to look at.
|
|
@@ -224,23 +326,35 @@ module Jekyll
|
|
|
224
326
|
def lint(content, document, root)
|
|
225
327
|
page = document && (document.relative_path || document.path).to_s
|
|
226
328
|
page = "(no page)" if page.nil? || page.empty?
|
|
227
|
-
|
|
329
|
+
# 0.2 lint reads no extensions (C2-W-109).
|
|
330
|
+
options = {}
|
|
228
331
|
options.update(root: root, source_path: document.path) if root
|
|
229
332
|
findings = ::Carve.lint(content, **options)
|
|
230
333
|
offset = front_matter_lines(document)
|
|
334
|
+
own = root && Pathname.new(document.path.to_s).relative_path_from(Pathname.new(root)).to_s
|
|
231
335
|
findings.each do |finding|
|
|
232
|
-
next if root && finding[:
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
336
|
+
next if root && finding[:code].start_with?("include-")
|
|
337
|
+
|
|
338
|
+
origin = finding[:file]
|
|
339
|
+
origin = nil if origin == own
|
|
340
|
+
text = origin ? File.read(File.join(root, origin), encoding: "utf-8") : content
|
|
341
|
+
line, column = position(text, finding.dig(:range, :startOffset).to_i)
|
|
342
|
+
where = if origin
|
|
343
|
+
"#{page} (#{origin}:#{line}:#{column})"
|
|
236
344
|
else
|
|
237
|
-
"#{page}:#{
|
|
345
|
+
"#{page}:#{line + offset}:#{column}"
|
|
238
346
|
end
|
|
239
|
-
Jekyll.logger.warn "Carve lint:", "#{where}: #{finding[:
|
|
347
|
+
Jekyll.logger.warn "Carve lint:", "#{where}: #{finding[:code]}: #{finding[:message]}"
|
|
240
348
|
end
|
|
241
349
|
@lint_findings = lint_findings + findings.size if lint_mode == :strict
|
|
242
350
|
end
|
|
243
351
|
|
|
352
|
+
# A 1-based line and character column for a UTF-8 byte offset in text.
|
|
353
|
+
def position(text, offset)
|
|
354
|
+
before = text.b[0, [offset, 0].max].force_encoding("utf-8").scrub("")
|
|
355
|
+
[before.count("\n") + 1, before.length - (before.rindex("\n") || -1)]
|
|
356
|
+
end
|
|
357
|
+
|
|
244
358
|
# Lines of YAML front matter above the body, so a finding names the line
|
|
245
359
|
# in the file. Jekyll strips the front matter before `convert` sees it.
|
|
246
360
|
def front_matter_lines(document)
|
|
@@ -252,12 +366,17 @@ module Jekyll
|
|
|
252
366
|
end
|
|
253
367
|
|
|
254
368
|
# Surface what expansion degraded, and record what it read.
|
|
369
|
+
#
|
|
370
|
+
# Carve 0.2 names the cause in the code (C2-N-061), so a missing file
|
|
371
|
+
# and a containment refusal are told apart by the warning itself.
|
|
255
372
|
def report_includes(result, document, root)
|
|
256
373
|
page = document.relative_path || document.path
|
|
257
374
|
Array(result[:warnings]).each do |warning|
|
|
375
|
+
next unless warning[:code].to_s.start_with?("include-") && warning[:channel] == "parse"
|
|
376
|
+
|
|
258
377
|
origin = warning[:file]
|
|
259
378
|
where = origin && origin != page ? "#{page} (#{origin})" : page
|
|
260
|
-
Jekyll.logger.warn "Carve:", "#{where}: #{warning[:
|
|
379
|
+
Jekyll.logger.warn "Carve:", "#{where}: #{warning[:code]}: #{warning[:message]}"
|
|
261
380
|
end
|
|
262
381
|
suppressed = result[:suppressedWarnings].to_i
|
|
263
382
|
if suppressed.positive?
|
|
@@ -265,16 +384,9 @@ module Jekyll
|
|
|
265
384
|
"#{page}: #{suppressed} further include warnings suppressed"
|
|
266
385
|
end
|
|
267
386
|
Array(result[:dependencies]).each do |dependency|
|
|
268
|
-
|
|
269
|
-
# page cannot probe the filesystem (spec I7). The class that was
|
|
270
|
-
# collapsed is here, for the build's own log.
|
|
271
|
-
if dependency[:denial]
|
|
272
|
-
Jekyll.logger.debug "Carve:",
|
|
273
|
-
"#{page}: include #{dependency[:path]}: #{dependency[:denial]}"
|
|
274
|
-
next
|
|
275
|
-
end
|
|
387
|
+
next unless dependency[:read] && dependency[:file]
|
|
276
388
|
|
|
277
|
-
register_dependency(document, File.join(root, dependency[:
|
|
389
|
+
register_dependency(document, File.join(root, dependency[:file].to_s))
|
|
278
390
|
end
|
|
279
391
|
end
|
|
280
392
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jekyll-carve
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
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-
|
|
11
|
+
date: 2026-12-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: carve-lang
|
|
@@ -16,20 +16,20 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
19
|
+
version: 0.2.0
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: 0.
|
|
22
|
+
version: 0.3.0
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version: 0.
|
|
29
|
+
version: 0.2.0
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.
|
|
32
|
+
version: 0.3.0
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: jekyll
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -84,7 +84,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
84
84
|
requirements:
|
|
85
85
|
- - ">="
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: 3.
|
|
87
|
+
version: 3.2.0
|
|
88
88
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements:
|
|
90
90
|
- - ">="
|