kramdown-ansi 0.6.0 → 0.8.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 +55 -0
- data/Rakefile +1 -1
- data/kramdown-ansi.gemspec +5 -5
- data/lib/kramdown/ansi/width.rb +3 -1
- data/lib/kramdown/ansi.rb +49 -26
- data/lib/kramdown/version.rb +1 -1
- data/scripts/capture-ansi +3 -0
- data/spec/assets/tables.ansi +70 -72
- data/spec/assets/tables.md +5 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bfce0110800a14de98f3322fa646e4432af3a51fcda9c278d5c631d322c2384d
|
|
4
|
+
data.tar.gz: fdad876925cd1ecab465d491b8cca2024dbc40b2e8d103794303b83e316aff3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 624287e2ab60beda1ce2ad7ce0ae3e68feeb8ad430b46828c7af3ee4833dd7d92c8a726919c4ebf6289a35fe79600d9756983e735403ef2269fa1ed3fd00a4a2
|
|
7
|
+
data.tar.gz: 795ffcabcd29c3910d1da3fca407ab2c09d85a416f25b0122353f0176ab59dcb424e869d9b4fac149cde62a03c1792f3b3134d24fe85b0b2c507112e8a181d41
|
data/CHANGES.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# Changes
|
|
2
2
|
|
|
3
|
+
## 2026-10-29 v0.8.0
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Fixed table width overflow by restructuring column width calculation from
|
|
8
|
+
per-row to per-table in `convert_table`, ensuring `Terminal::Table` is not
|
|
9
|
+
forced wider than the terminal by a single row's content distribution.
|
|
10
|
+
- Fixed a bug in `Kramdown::ANSI::Width.wrap` where a newline was incorrectly
|
|
11
|
+
prepended to the first token when it exceeded the target length, eliminating
|
|
12
|
+
phantom blank lines in narrow table cells.
|
|
13
|
+
- Subtracted table chrome (border, padding, and separator overhead) from the
|
|
14
|
+
column width budget in `convert_table` to prevent tables from exceeding
|
|
15
|
+
width.
|
|
16
|
+
|
|
17
|
+
### Improvements
|
|
18
|
+
|
|
19
|
+
- Simplified `convert_tr` to read pre-computed column widths and wrap each cell
|
|
20
|
+
to its fixed budget.
|
|
21
|
+
|
|
22
|
+
### Build & CI
|
|
23
|
+
|
|
24
|
+
- Updated the minimum version of the `gem_hadar` development dependency to
|
|
25
|
+
**2.21.0**.
|
|
26
|
+
- Bumped `rubygems_version` to **4.0.23**.
|
|
27
|
+
|
|
28
|
+
### Testing
|
|
29
|
+
|
|
30
|
+
- Regenerated `spec/assets/tables.ansi` golden file.
|
|
31
|
+
|
|
32
|
+
## 2026-10-22 v0.7.0
|
|
33
|
+
|
|
34
|
+
### Fixes
|
|
35
|
+
|
|
36
|
+
- Fixed GFM table parsing for non-header tables by rendering `:table` elements
|
|
37
|
+
without a `:thead` as plain text, as GFM requires a header row and delimiter
|
|
38
|
+
row for a valid table.
|
|
39
|
+
- Corrected table continuation detection in `self.parse` by checking if the
|
|
40
|
+
next line contains a `|`, resolving issues where delimiter or body rows
|
|
41
|
+
lacked a leading pipe (e.g., `:---|---:`, `1 | 2`).
|
|
42
|
+
|
|
43
|
+
### Improvements
|
|
44
|
+
|
|
45
|
+
- Replaced `Regexp.last_match` calls with direct captured group assignments
|
|
46
|
+
(`$1`, `$2`) in `ansi.rb` for clarity.
|
|
47
|
+
|
|
48
|
+
### Build & CI
|
|
49
|
+
|
|
50
|
+
- Added `scripts/capture-ansi` and `.envrc` for local golden file regeneration.
|
|
51
|
+
- Added `.envrc` and `scripts/*` to `package_ignore` in `Rakefile`.
|
|
52
|
+
|
|
53
|
+
### Testing
|
|
54
|
+
|
|
55
|
+
- Added Case 27 (pipe in a sentence) to `spec/assets/tables.md` and regenerated
|
|
56
|
+
`spec/assets/tables.ansi`.
|
|
57
|
+
|
|
3
58
|
## 2026-10-21 v0.6.0
|
|
4
59
|
|
|
5
60
|
### 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.8.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.8.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,18 +13,18 @@ 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]
|
|
20
20
|
s.required_ruby_version = Gem::Requirement.new(">= 3.1".freeze)
|
|
21
|
-
s.rubygems_version = "4.0.
|
|
21
|
+
s.rubygems_version = "4.0.23".freeze
|
|
22
22
|
s.summary = "Output markdown in the terminal with ANSI escape sequences".freeze
|
|
23
23
|
s.test_files = ["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]
|
|
24
24
|
|
|
25
25
|
s.specification_version = 4
|
|
26
26
|
|
|
27
|
-
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.
|
|
27
|
+
s.add_development_dependency(%q<gem_hadar>.freeze, [">= 2.21.0".freeze])
|
|
28
28
|
s.add_development_dependency(%q<all_images>.freeze, ["~> 0.4".freeze])
|
|
29
29
|
s.add_development_dependency(%q<rspec>.freeze, ["~> 3.2".freeze])
|
|
30
30
|
s.add_development_dependency(%q<debug>.freeze, [">= 0".freeze])
|
data/lib/kramdown/ansi/width.rb
CHANGED
|
@@ -78,7 +78,9 @@ module Kramdown::ANSI::Width
|
|
|
78
78
|
if $~[:nws]
|
|
79
79
|
if length_without_ansi + token_length > length
|
|
80
80
|
length_without_ansi = token_length
|
|
81
|
-
if result
|
|
81
|
+
if result.empty?
|
|
82
|
+
result = token_value
|
|
83
|
+
elsif result[-1] == ' '
|
|
82
84
|
result[-1, 1] = "\n#{token_value}"
|
|
83
85
|
else
|
|
84
86
|
result << "\n#{token_value}"
|
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,41 @@ 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
|
|
475
|
+
# Compute per-column budgets from the widest cell in each column
|
|
476
|
+
# across all rows. Terminal::Table sizes each column to its widest
|
|
477
|
+
# cell, so per-row ratios would produce columns wider than the
|
|
478
|
+
# terminal budget.
|
|
479
|
+
max_w = Hash.new(0)
|
|
480
|
+
el.children.each do |section|
|
|
481
|
+
next unless %i[thead tbody tfoot].include?(section.type)
|
|
482
|
+
section.children.each do |row|
|
|
483
|
+
row.children.each_with_index do |cell, i|
|
|
484
|
+
max_w[i] = [max_w[i], display_width(convert(cell, opts).strip)].max
|
|
485
|
+
end
|
|
486
|
+
end
|
|
487
|
+
end
|
|
488
|
+
n = max_w.keys.map(&:to_i).max.to_i + 1
|
|
489
|
+
total = max_w.values.sum
|
|
490
|
+
budget = width(percentage: 90) - (3 * n + 1)
|
|
491
|
+
col_w = if total.zero?
|
|
492
|
+
same = (budget.to_f / n).to_i
|
|
493
|
+
Array.new(n, same)
|
|
494
|
+
else
|
|
495
|
+
(0...n).map { |i| ((max_w[i].to_f / total) * budget).to_i }
|
|
496
|
+
end
|
|
497
|
+
opts[:table_col_widths] = col_w
|
|
464
498
|
table = Terminal::Table.new
|
|
465
499
|
table.style = {
|
|
466
500
|
all_separators: true,
|
|
@@ -522,33 +556,23 @@ class Kramdown::ANSI < Kramdown::Converter::Base
|
|
|
522
556
|
''
|
|
523
557
|
end
|
|
524
558
|
|
|
525
|
-
# The convert_tr method processes a table row element by
|
|
526
|
-
#
|
|
527
|
-
#
|
|
559
|
+
# The convert_tr method processes a table row element by wrapping each cell
|
|
560
|
+
# to the pre-computed column width and adding the formatted row to the
|
|
561
|
+
# terminal table instance.
|
|
528
562
|
#
|
|
529
563
|
# @param el [Kramdown::Element] the table row element to convert
|
|
530
564
|
# @param opts [Hash] conversion options containing context for processing
|
|
565
|
+
# (must include :table and :table_col_widths)
|
|
531
566
|
# @return [String] an empty string to indicate successful processing and
|
|
532
567
|
# addition of the row to the table instance
|
|
533
568
|
def convert_tr(el, opts)
|
|
534
569
|
return '' if el.children.empty?
|
|
535
|
-
|
|
570
|
+
col_w = opts[:table_col_widths]
|
|
571
|
+
cols = el.children.each_with_index.map do |c, i|
|
|
536
572
|
stripped = convert(c, opts).strip
|
|
537
|
-
stripped.empty? ? ' ' : stripped
|
|
538
|
-
end
|
|
539
|
-
return '' if cols.empty?
|
|
540
|
-
col_widths = cols.map { |c| display_width(c) }
|
|
541
|
-
col_widths_sum = col_widths.sum
|
|
542
|
-
full_width = width(percentage: 90)
|
|
543
|
-
ratios = cols.each_with_index.map do |c, i|
|
|
544
|
-
if col_widths_sum.zero?
|
|
545
|
-
1.0 / cols.size
|
|
546
|
-
else
|
|
547
|
-
col_widths[i] / col_widths_sum.to_f
|
|
548
|
-
end
|
|
573
|
+
stripped.empty? ? ' ' : wrap(stripped, length: col_w[i])
|
|
549
574
|
end
|
|
550
|
-
|
|
551
|
-
opts[:table] << wrapped_cols
|
|
575
|
+
opts[:table] << cols
|
|
552
576
|
''
|
|
553
577
|
end
|
|
554
578
|
|
|
@@ -651,5 +675,4 @@ class Kramdown::ANSI < Kramdown::Converter::Base
|
|
|
651
675
|
@ansi_styles.apply(name, &block)
|
|
652
676
|
end
|
|
653
677
|
end
|
|
654
|
-
|
|
655
678
|
Kramdown::Converter.const_set(:Ansi, Kramdown::ANSI)
|
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.8.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,70 +274,73 @@ 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
|
|
|
294
|
-
|
|
295
|
-
│ Case │ What It Stresses
|
|
296
|
-
|
|
297
|
-
│ 01 │ Column count validation / overflow / underflow
|
|
298
|
-
|
|
299
|
-
│ 02 │ Pipe-stripping logic (leading/trailing optional)
|
|
300
|
-
|
|
301
|
-
│ 03 │ Escape sequence handling ([34m\|[0m)
|
|
302
|
-
|
|
303
|
-
│ 04 │ Empty-string cell rendering, border alignment
|
|
304
|
-
|
|
305
|
-
│ 05 │ Single-column edge (degenerate table)
|
|
306
|
-
|
|
307
|
-
│ 06 │ Zero data rows — does it draw a header-only box?
|
|
308
|
-
|
|
309
|
-
│ 07 │ Consecutive tables — does the second become data of the
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
289
|
+
╭──────┬─────────────────────────────────────────────────────────╮
|
|
290
|
+
│ Case │ What It Stresses │
|
|
291
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
292
|
+
│ 01 │ Column count validation / overflow / underflow │
|
|
293
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
294
|
+
│ 02 │ Pipe-stripping logic (leading/trailing optional) │
|
|
295
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
296
|
+
│ 03 │ Escape sequence handling ([34m\|[0m) │
|
|
297
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
298
|
+
│ 04 │ Empty-string cell rendering, border alignment │
|
|
299
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
300
|
+
│ 05 │ Single-column edge (degenerate table) │
|
|
301
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
302
|
+
│ 06 │ Zero data rows — does it draw a header-only box? │
|
|
303
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
304
|
+
│ 07 │ Consecutive tables — does the second become data of the │
|
|
305
|
+
│ │ first? │
|
|
306
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
307
|
+
│ 08 │ Unicode width calculation for column sizing │
|
|
308
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
309
|
+
│ 09 │ Inline markdown rendering [3minside[0m a table cell │
|
|
310
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
311
|
+
│ 10 │ Alignment row with fewer columns than header │
|
|
312
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
313
|
+
│ 11 │ Blank line splitting one table into two │
|
|
314
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
315
|
+
│ 12 │ Whitespace normalization / trimming │
|
|
316
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
317
|
+
│ 13 │ Raw HTML + [34m<br>[0m in cell context │
|
|
318
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
319
|
+
│ 14 │ Cell with only whitespace — empty or not? │
|
|
320
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
321
|
+
│ 15 │ Very wide table — does it wrap or overflow? │
|
|
322
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
323
|
+
│ 16 │ Non-standard alignment markers │
|
|
324
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
325
|
+
│ 17 │ Table at doc start, glued to following header │
|
|
326
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
327
|
+
│ 18 │ Table glued to preceding header (no blank before) │
|
|
328
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
329
|
+
│ 19 │ Single col, missing closing pipe on header │
|
|
330
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
331
|
+
│ 20 │ Not a table: single pipe line │
|
|
332
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
333
|
+
│ 21 │ Not a table: header + sep, no body, missing pipe │
|
|
334
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
335
|
+
│ 22 │ Table after code block, no blank between │
|
|
336
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
337
|
+
│ 23 │ Table after list item, no blank between │
|
|
338
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
339
|
+
│ 24 │ No leading pipe on separator row │
|
|
340
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
341
|
+
│ 25 │ No leading pipe on body row │
|
|
342
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
343
|
+
│ 26 │ Indented table inside ordered list item │
|
|
344
|
+
├──────┼─────────────────────────────────────────────────────────┤
|
|
345
|
+
│ 27 │ Not a table just a pipe in a sentence │
|
|
346
|
+
╰──────┴─────────────────────────────────────────────────────────╯
|
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.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Florian Frank
|
|
@@ -15,14 +15,14 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: 2.
|
|
18
|
+
version: 2.21.0
|
|
19
19
|
type: :development
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: 2.
|
|
25
|
+
version: 2.21.0
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: all_images
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -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
|
|
@@ -232,7 +233,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
232
233
|
- !ruby/object:Gem::Version
|
|
233
234
|
version: '0'
|
|
234
235
|
requirements: []
|
|
235
|
-
rubygems_version: 4.0.
|
|
236
|
+
rubygems_version: 4.0.23
|
|
236
237
|
specification_version: 4
|
|
237
238
|
summary: Output markdown in the terminal with ANSI escape sequences
|
|
238
239
|
test_files:
|