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 +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +1 -1
- data/lib/papercraft/compiler/tag_translator.rb +7 -2
- data/lib/papercraft/compiler.rb +4 -3
- data/lib/papercraft/version.rb +1 -1
- data/lib/papercraft.rb +16 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c181e3d6f6fc6784a97d7816ad6ea495a5622188977e76035454186d0e5a552
|
4
|
+
data.tar.gz: a6528a61e5a19670a08460e6e2ffe903f7651fecad30d7400fc0df948fbaaa5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4cecc6a0555b0adc78ef128ed9c650303d2fd487dbc160365500ed029538cb2d7b394f1a025d152bfa3cc2476986defca15066992047be01975fd410ac66015
|
7
|
+
data.tar.gz: 017e02aeb60cd4bd690e355fb9a34a25d7dd93e2b8d424e46b407791070776cb35e1d8ed423d07f62746a276ba98e6abd61813c67bca7a061f807abd0fc11c71
|
data/CHANGELOG.md
CHANGED
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
|
data/lib/papercraft/compiler.rb
CHANGED
@@ -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
|
209
|
+
emit(format_code(node.call_node.receiver))
|
209
210
|
emit('::')
|
210
211
|
end
|
211
|
-
emit("
|
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>')
|
data/lib/papercraft/version.rb
CHANGED
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
|
-
#
|
98
|
-
# default Kramdown options in order to change the rendering
|
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 [
|
103
|
-
def
|
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)
|
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.
|