papercraft 2.14 → 2.15

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: 97d2e54989eea3ae631687adb3e484779d48d38d5251705e9fab7f8dd0e0b964
4
+ data.tar.gz: 02e161802820d2978e04033fa69a8d8850beeab7bc101a8020e7d4ba7262e204
5
5
  SHA512:
6
- metadata.gz: 4360ecfe28aedacb33d6b4b77f1715289c3831a09629cdb398fb16b8319ce603bbd47f565720aca2120efafa9add694bcbd783d06682f72f199844f24a318934
7
- data.tar.gz: 6fa327527d4221bf2527be387ffc9b9a2a1504d5f91e761793f572eb55f7ddaf3914ee1849f8ab434043bc52f3fc4efd690a130e49c742d413005c0432f88c44
6
+ metadata.gz: c293bb44d8e53aedb3b19fdc45ea61956ef97637ba387e78180bb854fc5c445502968a38739211ae951c3c00355a42259ee5b3a418994804723615c44be6430d
7
+ data.tar.gz: 514a56dc9cb1920209b08fa07a93a631c68352539f27d41be8a39038a65cb48af48bfda598c5091f00c17c50cb12a820bc5e9f6c65d2740323b2baf4761271cc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 2.15 2025-10-01
2
+
3
+ - Add `Papercraft.markdown_doc` method
4
+ - Emit DOCTYPE for `#html` as well as `#html5`
5
+
1
6
  # 2.14 2025-09-17
2
7
 
3
8
  - 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
@@ -310,7 +310,7 @@ module Papercraft
310
310
  case node.tag
311
311
  when :tag
312
312
  args = node.call_node.arguments&.arguments
313
- when :html5
313
+ when :html, :html5
314
314
  emit_html(node.location, '<!DOCTYPE html><html>')
315
315
  visit(node.block.body) if node.block
316
316
  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.15'
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.15'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner