kramdown-ansi 0.6.0 → 0.7.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/CHANGES.md +26 -0
- data/Rakefile +1 -1
- data/kramdown-ansi.gemspec +3 -3
- data/lib/kramdown/ansi.rb +18 -7
- data/lib/kramdown/version.rb +1 -1
- data/scripts/capture-ansi +3 -0
- data/spec/assets/tables.ansi +14 -17
- data/spec/assets/tables.md +5 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6d35fcfbc735d86a3f58f59c1eaded0ebdc4f706db3cedb0c807aa6f9f420fe8
|
|
4
|
+
data.tar.gz: cd32746d6d592ee48e59bda8211adf670bdef612a5c65da97e114234ef8f0e83
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d7607e68a92ac9d968febb1179c60a291550306b56ada967fd29f2c9f1dd413f6d18981895b358b5a0ac34bdaae0291d1ed7e452a76dbe52329582fc11b11dc5
|
|
7
|
+
data.tar.gz: 07b078aad8c0e3d0b9cf1b509b9f21dc4a2cbdbf3101f4997a079349fb7272848fe58080a18ab4e79c4b13b07061cbe61dfb43c511b8630eb73c077a6ecb866b
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-10-22 v0.7.0
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Fixed GFM table parsing for non-header tables by rendering `:table` elements
|
|
8
|
+
without a `:thead` as plain text, as GFM requires a header row and delimiter
|
|
9
|
+
row for a valid table.
|
|
10
|
+
- Corrected table continuation detection in `self.parse` by checking if the
|
|
11
|
+
next line contains a `|`, resolving issues where delimiter or body rows
|
|
12
|
+
lacked a leading pipe (e.g., `:---|---:`, `1 | 2`).
|
|
13
|
+
|
|
14
|
+
### Improvements
|
|
15
|
+
|
|
16
|
+
- Replaced `Regexp.last_match` calls with direct captured group assignments
|
|
17
|
+
(`$1`, `$2`) in `ansi.rb` for clarity.
|
|
18
|
+
|
|
19
|
+
### Build & CI
|
|
20
|
+
|
|
21
|
+
- Added `scripts/capture-ansi` and `.envrc` for local golden file regeneration.
|
|
22
|
+
- Added `.envrc` and `scripts/*` to `package_ignore` in `Rakefile`.
|
|
23
|
+
|
|
24
|
+
### Testing
|
|
25
|
+
|
|
26
|
+
- Added Case 27 (pipe in a sentence) to `spec/assets/tables.md` and regenerated
|
|
27
|
+
`spec/assets/tables.ansi`.
|
|
28
|
+
|
|
3
29
|
## 2026-10-21 v0.6.0
|
|
4
30
|
|
|
5
31
|
### Features
|
data/Rakefile
CHANGED
|
@@ -19,7 +19,7 @@ GemHadar do
|
|
|
19
19
|
'.yardoc', 'doc', 'tags', 'errors.lst', 'cscope.out', 'coverage', 'tmp',
|
|
20
20
|
'yard'
|
|
21
21
|
package_ignore '.all_images.yml', '.tool-versions', '.gitignore', 'VERSION',
|
|
22
|
-
'.rspec', '.github'
|
|
22
|
+
'.rspec', '.github', '.envrc', 'scripts/*'
|
|
23
23
|
readme 'README.md'
|
|
24
24
|
|
|
25
25
|
executables << 'md' << 'git-md'
|
data/kramdown-ansi.gemspec
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
|
-
# stub: kramdown-ansi 0.
|
|
2
|
+
# stub: kramdown-ansi 0.7.0 ruby lib
|
|
3
3
|
|
|
4
4
|
Gem::Specification.new do |s|
|
|
5
5
|
s.name = "kramdown-ansi".freeze
|
|
6
|
-
s.version = "0.
|
|
6
|
+
s.version = "0.7.0".freeze
|
|
7
7
|
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
9
9
|
s.require_paths = ["lib".freeze]
|
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
|
13
13
|
s.email = "flori@ping.de".freeze
|
|
14
14
|
s.executables = ["md".freeze, "git-md".freeze]
|
|
15
15
|
s.extra_rdoc_files = ["README.md".freeze, "lib/kramdown/ansi.rb".freeze, "lib/kramdown/ansi/pager.rb".freeze, "lib/kramdown/ansi/styles.rb".freeze, "lib/kramdown/ansi/width.rb".freeze, "lib/kramdown/version.rb".freeze]
|
|
16
|
-
s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/git-md".freeze, "bin/md".freeze, "img/git-md.png".freeze, "img/md.png".freeze, "kramdown-ansi.gemspec".freeze, "lib/kramdown/ansi.rb".freeze, "lib/kramdown/ansi/pager.rb".freeze, "lib/kramdown/ansi/styles.rb".freeze, "lib/kramdown/ansi/width.rb".freeze, "lib/kramdown/version.rb".freeze, "spec/assets/README.ansi".freeze, "spec/assets/html.ansi".freeze, "spec/assets/html.md".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/tables.ansi".freeze, "spec/assets/tables.md".freeze, "spec/kramdown/ansi/pager_spec.rb".freeze, "spec/kramdown/ansi/styles_spec.rb".freeze, "spec/kramdown/ansi/width_spec.rb".freeze, "spec/kramdown/ansi_golden_spec.rb".freeze, "spec/kramdown/ansi_spec.rb".freeze, "spec/kramdown/ansi_table_spec.rb".freeze, "spec/kramdown/render_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.gitkeep".freeze]
|
|
16
|
+
s.files = [".utilsrc".freeze, "CHANGES.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "Rakefile".freeze, "bin/git-md".freeze, "bin/md".freeze, "img/git-md.png".freeze, "img/md.png".freeze, "kramdown-ansi.gemspec".freeze, "lib/kramdown/ansi.rb".freeze, "lib/kramdown/ansi/pager.rb".freeze, "lib/kramdown/ansi/styles.rb".freeze, "lib/kramdown/ansi/width.rb".freeze, "lib/kramdown/version.rb".freeze, "scripts/capture-ansi".freeze, "spec/assets/README.ansi".freeze, "spec/assets/html.ansi".freeze, "spec/assets/html.md".freeze, "spec/assets/kitten.jpg".freeze, "spec/assets/tables.ansi".freeze, "spec/assets/tables.md".freeze, "spec/kramdown/ansi/pager_spec.rb".freeze, "spec/kramdown/ansi/styles_spec.rb".freeze, "spec/kramdown/ansi/width_spec.rb".freeze, "spec/kramdown/ansi_golden_spec.rb".freeze, "spec/kramdown/ansi_spec.rb".freeze, "spec/kramdown/ansi_table_spec.rb".freeze, "spec/kramdown/render_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tmp/.gitkeep".freeze]
|
|
17
17
|
s.homepage = "https://github.com/flori/kramdown-ansi".freeze
|
|
18
18
|
s.licenses = ["MIT".freeze]
|
|
19
19
|
s.rdoc_options = ["--title".freeze, "Kramdown-ansi - Output markdown in the terminal with ANSI escape sequences".freeze, "--main".freeze, "README.md".freeze]
|
data/lib/kramdown/ansi.rb
CHANGED
|
@@ -110,15 +110,14 @@ class Kramdown::ANSI < Kramdown::Converter::Base
|
|
|
110
110
|
)
|
|
111
111
|
# Insert blank line after a table's last row when glued to
|
|
112
112
|
# following content; kramdown requires it to close the table.
|
|
113
|
+
#
|
|
114
|
+
# A following line that contains a pipe is likely a table row
|
|
115
|
+
# (separator or body), so we keep it glued.
|
|
113
116
|
source = source.gsub(
|
|
114
|
-
/(\|[^\n]*\n)([^|\n])
|
|
117
|
+
/(\|[^\n]*\n)([^|\n][^\n]*)/
|
|
115
118
|
) do |match|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
match
|
|
119
|
-
else
|
|
120
|
-
"#{Regexp.last_match(1)}\n#{next_char}"
|
|
121
|
-
end
|
|
119
|
+
row, next_line = $1, $2
|
|
120
|
+
next_line.include?('|') ? match : "#{row}\n#{next_line}"
|
|
122
121
|
end
|
|
123
122
|
@doc = Kramdown::Document.new(source, options).to_ansi
|
|
124
123
|
end
|
|
@@ -461,6 +460,18 @@ class Kramdown::ANSI < Kramdown::Converter::Base
|
|
|
461
460
|
# @param opts [Hash] conversion options containing context for processing
|
|
462
461
|
# @return [String] the formatted table content with proper styling and newlines
|
|
463
462
|
def convert_table(el, opts)
|
|
463
|
+
# Kramdown's base parser is more permissive than GFM: it accepts
|
|
464
|
+
# any pipe-delimited line as a table row, even without a header.
|
|
465
|
+
# GFM mandates a header + separator row minimum, so a :table
|
|
466
|
+
# element without :thead is just pipe-separated prose.
|
|
467
|
+
unless el.children.any? { |c| c.type == :thead }
|
|
468
|
+
rows = el.children.select { |c| c.type == :tbody }.flat_map do |tbody|
|
|
469
|
+
tbody.children.map do |row|
|
|
470
|
+
row.children.map { |cell| convert(cell, opts).strip }.join(' | ')
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
return newline rows.join("\n")
|
|
474
|
+
end
|
|
464
475
|
table = Terminal::Table.new
|
|
465
476
|
table.style = {
|
|
466
477
|
all_separators: true,
|
data/lib/kramdown/version.rb
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# by hand; it is rewritten on every `rake version` invocation.
|
|
6
6
|
module Kramdown
|
|
7
7
|
# The current version of the Kramdown gem as a String.
|
|
8
|
-
VERSION = '0.
|
|
8
|
+
VERSION = '0.7.0'
|
|
9
9
|
VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
|
|
10
10
|
VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
|
|
11
11
|
VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
|
data/spec/assets/tables.ansi
CHANGED
|
@@ -225,9 +225,7 @@ Bold, italic, code, links, strikethrough, nested.
|
|
|
225
225
|
|
|
226
226
|
[1m[4mCase 20 — Not a Table: Single Pipe Line[0m[0m
|
|
227
227
|
|
|
228
|
-
|
|
229
|
-
│ not a table │
|
|
230
|
-
╰─────────────╯
|
|
228
|
+
not a table
|
|
231
229
|
|
|
232
230
|
[1m[4mCase 21 — Not a Table: Header + Sep, No Body, Missing Closing Pipe[0m[0m
|
|
233
231
|
|
|
@@ -260,18 +258,15 @@ Bold, italic, code, links, strikethrough, nested.
|
|
|
260
258
|
|
|
261
259
|
╭───┬───╮
|
|
262
260
|
│ a │ b │
|
|
261
|
+
├───┼───┤
|
|
262
|
+
│ 1 │ 2 │
|
|
263
263
|
╰───┴───╯
|
|
264
264
|
|
|
265
|
-
╭───┬───┬───╮
|
|
266
|
-
│ │ 1 │ 2 │
|
|
267
|
-
╰───┴───┴───╯
|
|
268
|
-
|
|
269
265
|
[1m[4mCase 25 — No Leading Pipe on Body Row[0m[0m
|
|
270
266
|
|
|
271
|
-
| a | b |
|
|
272
|
-
|---|---|
|
|
273
|
-
|
|
274
267
|
╭───┬───╮
|
|
268
|
+
│ a │ b │
|
|
269
|
+
├───┼───┤
|
|
275
270
|
│ 1 │ 2 │
|
|
276
271
|
╰───┴───╯
|
|
277
272
|
|
|
@@ -279,15 +274,15 @@ Bold, italic, code, links, strikethrough, nested.
|
|
|
279
274
|
|
|
280
275
|
1. [1mFlatten it.[0m
|
|
281
276
|
|
|
282
|
-
|
|
283
|
-
│ Service
|
|
284
|
-
|
|
277
|
+
╭─────────────┬───────────────┬───────╮
|
|
278
|
+
│ Service │ Sub │ Value │
|
|
279
|
+
├─────────────┼───────────────┼───────┤
|
|
280
|
+
│ [34mollama_chat[0m │ [34mkramdown-ansi[0m │ 🟢 │
|
|
281
|
+
╰─────────────┴───────────────┴───────╯
|
|
285
282
|
|
|
286
|
-
|
|
283
|
+
[1m[4mCase 27 — Not a table just a pipe in a sentence[0m[0m
|
|
287
284
|
|
|
288
|
-
|
|
289
|
-
│ [34mollama_chat[0m │ [34mkramdown-ansi[0m │ 🟢 │
|
|
290
|
-
╰─────────────┴───────────────┴────╯
|
|
285
|
+
a | b
|
|
291
286
|
|
|
292
287
|
────────────────────────────────────────────────────────────────────────────────
|
|
293
288
|
|
|
@@ -345,4 +340,6 @@ Bold, italic, code, links, strikethrough, nested.
|
|
|
345
340
|
│ 25 │ No leading pipe on body row │
|
|
346
341
|
├──────┼────────────────────────────────────────────────────────────────┤
|
|
347
342
|
│ 26 │ Indented table inside ordered list item │
|
|
343
|
+
├──────┼────────────────────────────────────────────────────────────────┤
|
|
344
|
+
│ 27 │ Not a table just a pipe in a sentence │
|
|
348
345
|
╰──────┴────────────────────────────────────────────────────────────────╯
|
data/spec/assets/tables.md
CHANGED
|
@@ -204,6 +204,10 @@ some code
|
|
|
204
204
|
|:--------|:----|:------|
|
|
205
205
|
| `ollama_chat` | `kramdown-ansi` | 🟢 |
|
|
206
206
|
|
|
207
|
+
## Case 27 — Not a table just a pipe in a sentence
|
|
208
|
+
|
|
209
|
+
a | b
|
|
210
|
+
|
|
207
211
|
---
|
|
208
212
|
|
|
209
213
|
| Case | What It Stresses |
|
|
@@ -234,3 +238,4 @@ some code
|
|
|
234
238
|
| 24 | No leading pipe on separator row |
|
|
235
239
|
| 25 | No leading pipe on body row |
|
|
236
240
|
| 26 | Indented table inside ordered list item |
|
|
241
|
+
| 27 | Not a table just a pipe in a sentence |
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kramdown-ansi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -195,6 +195,7 @@ files:
|
|
|
195
195
|
- lib/kramdown/ansi/styles.rb
|
|
196
196
|
- lib/kramdown/ansi/width.rb
|
|
197
197
|
- lib/kramdown/version.rb
|
|
198
|
+
- scripts/capture-ansi
|
|
198
199
|
- spec/assets/README.ansi
|
|
199
200
|
- spec/assets/html.ansi
|
|
200
201
|
- spec/assets/html.md
|