protos-markdown 1.1.0 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef97dcc38918f4650f93eecd010522e60f435326b1c5330855b277063bf91c2d
4
- data.tar.gz: 45986e32975fb362c82c1c7428450d6a64b6237c1e722039b1bc91ca24d57d1e
3
+ metadata.gz: 149154ed4ed5d1bff8bcf411e6e8cae01b35f2103586420154bd6180096299d0
4
+ data.tar.gz: 7ec3a0c2fa97be4d83d5adcea88726c59a94b136ee13b2601ef09e3d4f05ff2d
5
5
  SHA512:
6
- metadata.gz: edde7fdbe9ed89febeb5fe007bd5f7a3bc382277fe68a02949f0054d68ac427daa281a208f66eae358b29479c4c782f9759206dde3ad1f32a51a5be3870e2102
7
- data.tar.gz: f8baa177b747fea06e86452a221ad39042cec9a43c699f9159e4840c9e9170cd7c7950c8d97c05c468136112f94303fbca030f4671a6423ef6a1cdca1ce4ec28
6
+ metadata.gz: 8c690286a4117d42ec8cc7e65406a16c2bb53a2b27a91a7b00526b6dc2adf13dc9fd26eaf001f1a652e159725cdf5bd6703f403e07fd9c4654fc5dc20272d4fd
7
+ data.tar.gz: a62bf4a662a89ed16e714b824df65e2f12874f62e73a3b7b09c29efdc7eac8afb89d9950d699795886bbe1bacd175cffd339ed7c3c93cde4893914e7bff8b644
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## 1.2.0 - 2025-12-25
4
+
5
+ - Adds handling inline html elements
6
+ - Adds handling more nodes for markdown tables
7
+ - Adds handling inline html blocks
8
+
9
+ ## [1.1.0] - 2024-05-28
10
+
11
+ - Changes from `markly` to `commonmarker` which has better support
12
+ - Adds IDs to headings by default
13
+ - Adds ability to override common marker options with `markdown_options`
14
+
3
15
  ## [0.1.1] - 2024-08-14
4
16
 
5
17
  - Adds `rouge` to gem dependencies
@@ -4,11 +4,16 @@ module Protos
4
4
  class Markdown
5
5
  class Table < Protos::Table
6
6
  option :inside_header, default: -> { true }, reader: false
7
+ option :sanitize, default: -> { true }
7
8
 
8
9
  def visit_table(node)
9
10
  visit_children(node)
10
11
  end
11
12
 
13
+ def visit_image(node)
14
+ img(src: node.url, alt: node.first&.string_content)
15
+ end
16
+
12
17
  def visit_table_header(node)
13
18
  @inside_header = true
14
19
 
@@ -45,6 +50,20 @@ module Protos
45
50
  strong { visit_children(node) }
46
51
  end
47
52
 
53
+ def visit_emph(node)
54
+ em { visit_children(node) }
55
+ end
56
+
57
+ def visit_html_inline(node)
58
+ return if @sanitize
59
+
60
+ raw safe(node.to_html(options: { render: { unsafe: true } }))
61
+ end
62
+
63
+ def visit_link(node)
64
+ a(href: node.url, title: node.title) { visit_children(node) }
65
+ end
66
+
48
67
  private
49
68
 
50
69
  def visit_children(node)
@@ -10,9 +10,9 @@ require_relative "markdown/table"
10
10
 
11
11
  module Protos
12
12
  class Markdown < ::Protos::Component # rubocop:disable Metrics/ClassLength
13
- param :content, reader: false
14
- option :sanitize, default: -> { true }, reader: false
15
- option :markdown_options, default: -> { {} }, reader: false
13
+ param :content
14
+ option :sanitize, default: -> { true }
15
+ option :markdown_options, default: -> { {} }
16
16
 
17
17
  Heading = Data.define(:node) do
18
18
  def id
@@ -44,8 +44,12 @@ module Protos
44
44
  # Do nothing
45
45
  end
46
46
 
47
+ def visit_linebreak(_node)
48
+ br
49
+ end
50
+
47
51
  def visit_table(node)
48
- render Markdown::Table.new do |table|
52
+ render Markdown::Table.new(sanitize:) do |table|
49
53
  node.accept(table)
50
54
  end
51
55
  end
@@ -149,8 +153,10 @@ module Protos
149
153
  raw safe(node.to_html(options: { render: { unsafe: true } }))
150
154
  end
151
155
 
152
- def visit_html_block(_node)
153
- nil
156
+ def visit_html_block(node)
157
+ return if @sanitize
158
+
159
+ raw safe(node.to_html(options: { render: { unsafe: true } }))
154
160
  end
155
161
 
156
162
  def visit_escaped(node)
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "protos-markdown"
5
- spec.version = "1.1.0"
5
+ spec.version = "1.2.0"
6
6
  spec.authors = ["Nolan Tait"]
7
7
  spec.email = ["nolanjtait@gmail.com"]
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protos-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nolan Tait
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
- rubygems_version: 3.6.7
95
+ rubygems_version: 4.0.3
96
96
  specification_version: 4
97
97
  summary: A markdown renderer with Phlex and Protos
98
98
  test_files: []