papercraft 2.14 → 2.16

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: 778a543052eef0a1901172f1655da8ca1bfadce65699e70cdb42abf0f690b5da
4
- data.tar.gz: 2268982f7ff3476073eb40e3b76e4061cde3c521fb68864b47ca46fabda9833b
3
+ metadata.gz: 3c181e3d6f6fc6784a97d7816ad6ea495a5622188977e76035454186d0e5a552
4
+ data.tar.gz: a6528a61e5a19670a08460e6e2ffe903f7651fecad30d7400fc0df948fbaaa5d
5
5
  SHA512:
6
- metadata.gz: 4360ecfe28aedacb33d6b4b77f1715289c3831a09629cdb398fb16b8319ce603bbd47f565720aca2120efafa9add694bcbd783d06682f72f199844f24a318934
7
- data.tar.gz: 6fa327527d4221bf2527be387ffc9b9a2a1504d5f91e761793f572eb55f7ddaf3914ee1849f8ab434043bc52f3fc4efd690a130e49c742d413005c0432f88c44
6
+ metadata.gz: f4cecc6a0555b0adc78ef128ed9c650303d2fd487dbc160365500ed029538cb2d7b394f1a025d152bfa3cc2476986defca15066992047be01975fd410ac66015
7
+ data.tar.gz: 017e02aeb60cd4bd690e355fb9a34a25d7dd93e2b8d424e46b407791070776cb35e1d8ed423d07f62746a276ba98e6abd61813c67bca7a061f807abd0fc11c71
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ # 2.16 2025-10-02
2
+
3
+ - Add support for namespaced components
4
+
5
+ # 2.15 2025-10-01
6
+
7
+ - Add `Papercraft.markdown_doc` method
8
+ - Emit DOCTYPE for `#html` as well as `#html5`
9
+
1
10
  # 2.14 2025-09-17
2
11
 
3
12
  - Do not escape inner text of style and script tags
data/README.md CHANGED
@@ -305,7 +305,7 @@ large_button = ->(title) { button(title, class: 'large') }
305
305
  }.render #=> <button class="large">foo</button>
306
306
  ```
307
307
 
308
- ### `#html5` - emit an HTML5 document type declaration and html tag
308
+ ### `#html`/`#html5` - emit an HTML5 document type declaration and html tag
309
309
 
310
310
  ```ruby
311
311
  -> {
@@ -48,7 +48,7 @@ module Papercraft
48
48
  TextNode.new(node, self)
49
49
  when :defer
50
50
  DeferNode.new(node, self)
51
- when :html5, :markdown
51
+ when :html, :html5, :markdown
52
52
  BuiltinNode.new(node, self)
53
53
  else
54
54
  nil
@@ -63,8 +63,13 @@ module Papercraft
63
63
  end
64
64
 
65
65
  def match_const_tag(node)
66
- return if node.receiver
67
66
  return if node.name !~ /^[A-Z]/
67
+ case node.receiver
68
+ when nil, Prism::ConstantReadNode, Prism::ConstantPathNode
69
+ # ok
70
+ else
71
+ return
72
+ end
68
73
 
69
74
  ConstTagNode.new(node, self)
70
75
  end
@@ -204,11 +204,12 @@ module Papercraft
204
204
  def visit_const_tag_node(node)
205
205
  flush_html_parts!
206
206
  adjust_whitespace(node.location)
207
+ emit("; ")
207
208
  if node.call_node.receiver
208
- emit(node.call_node.receiver.location)
209
+ emit(format_code(node.call_node.receiver))
209
210
  emit('::')
210
211
  end
211
- emit("; #{node.call_node.name}.compiled_proc.(__buffer__")
212
+ emit("#{node.call_node.name}.compiled_proc.(__buffer__")
212
213
  if node.call_node.arguments
213
214
  emit(', ')
214
215
  visit(node.call_node.arguments)
@@ -310,7 +311,7 @@ module Papercraft
310
311
  case node.tag
311
312
  when :tag
312
313
  args = node.call_node.arguments&.arguments
313
- when :html5
314
+ when :html, :html5
314
315
  emit_html(node.location, '<!DOCTYPE html><html>')
315
316
  visit(node.block.body) if node.block
316
317
  emit_html(node.block.closing_loc, '</html>')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Papercraft
4
- VERSION = '2.14'
4
+ VERSION = '2.16'
5
5
  end
data/lib/papercraft.rb CHANGED
@@ -94,13 +94,14 @@ module Papercraft
94
94
  ArgumentError.new(message).tap { it.set_backtrace(backtrace) }
95
95
  end
96
96
 
97
- # Renders Markdown into HTML. The `opts` argument will be merged with the
98
- # default Kramdown options in order to change the rendering behaviour.
97
+ # Returns a Kramdown doc for the given markdown. The `opts` argument will be
98
+ # merged with the default Kramdown options in order to change the rendering
99
+ # behaviour.
99
100
  #
100
101
  # @param markdown [String] Markdown
101
102
  # @param opts [Hash] Kramdown option overrides
102
- # @return [String] HTML
103
- def markdown(markdown, **opts)
103
+ # @return [Kramdown::Document] Kramdown document
104
+ def markdown_doc(markdown, **opts)
104
105
  @markdown_deps_loaded ||= true.tap do
105
106
  require 'kramdown'
106
107
  require 'rouge'
@@ -108,7 +109,17 @@ module Papercraft
108
109
  end
109
110
 
110
111
  opts = default_kramdown_options.merge(opts)
111
- Kramdown::Document.new(markdown, **opts).to_html
112
+ Kramdown::Document.new(markdown, **opts)
113
+ end
114
+
115
+ # Renders Markdown into HTML. The `opts` argument will be merged with the
116
+ # default Kramdown options in order to change the rendering behaviour.
117
+ #
118
+ # @param markdown [String] Markdown
119
+ # @param opts [Hash] Kramdown option overrides
120
+ # @return [String] HTML
121
+ def markdown(markdown, **opts)
122
+ markdown_doc(markdown, **opts).to_html
112
123
  end
113
124
 
114
125
  # Returns the default Kramdown options used for rendering Markdown.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papercraft
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.14'
4
+ version: '2.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner