raindown 0.5.0 → 0.5.1
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/lib/raindown/actions.rb +1 -1
- data/lib/raindown/bare_directives.rb +14 -3
- data/lib/raindown/document.rb +3 -3
- data/lib/raindown/endpoint/endpoint_runner.rb +1 -1
- data/lib/raindown/node_injector.rb +1 -1
- data/lib/raindown.rb +2 -0
- data/lib/version.rb +1 -1
- 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: 9e35dfde9371c5f805bff304124c0abe22ca89254f14c5c70d2996e14d0dbb0f
|
|
4
|
+
data.tar.gz: 76774aa6b06fec8b50e0929b9ac86259511fb1ab9417ce48fcfa56afd20c90cf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 454c35bfd6c74cc2c125d8229ffe971cb178fb40f4d87affad0fc5d345301fd4d5a0e32a15852f05eb35231e0054b2a5b55ff2a4eb7253cc85aef17f4d17e178
|
|
7
|
+
data.tar.gz: 33b41ed491f7cc8238f3c3d99b2d72e2b0197dce29146dd14bdc704dd0ea6fa64788c97ed5d60bda60ef4602e9e6dedb2d22b02a1f8886a5c4592a522d96886e
|
data/lib/raindown/actions.rb
CHANGED
|
@@ -30,7 +30,7 @@ module Raindown
|
|
|
30
30
|
raise NotAnEndpoint, "#{directive.name} on line #{directive.line} isn't an endpoint" unless directive.endpoint?
|
|
31
31
|
|
|
32
32
|
content = File.read(path, encoding: Encoding::UTF_8)
|
|
33
|
-
rewritten = EndpointRunner.new(content:, bare: BareDirectives.
|
|
33
|
+
rewritten = EndpointRunner.new(content:, bare: BareDirectives.enabled?(path:, content:), only: directive.line - 1).rewrite
|
|
34
34
|
return false if rewritten == content
|
|
35
35
|
|
|
36
36
|
File.write(path, rewritten)
|
|
@@ -5,7 +5,8 @@ require_relative 'front_matter'
|
|
|
5
5
|
|
|
6
6
|
module Raindown
|
|
7
7
|
# Raindown files (.rd/.raindown) can write a directive like <{ if: draft }> as a bare if: draft on its own line.
|
|
8
|
-
# Markdown files opt in with
|
|
8
|
+
# Markdown files opt in with "raindown: true" in their front matter, or with the --bare flag.
|
|
9
|
+
# Nodes like toc: and files: are handled by NodeBlocks, before the rest.
|
|
9
10
|
#
|
|
10
11
|
# Bare directives have no end tag. A bare block directive closes itself after the content it applies to,
|
|
11
12
|
# so where a block needs to wrap more than that, write it with delimiters and an end tag instead:
|
|
@@ -24,8 +25,8 @@ module Raindown
|
|
|
24
25
|
|
|
25
26
|
module_function
|
|
26
27
|
|
|
27
|
-
def enabled?(path: nil, bare: false)
|
|
28
|
-
bare || file?(path)
|
|
28
|
+
def enabled?(path: nil, content: nil, bare: false)
|
|
29
|
+
bare || file?(path) || front_matter?(content)
|
|
29
30
|
end
|
|
30
31
|
|
|
31
32
|
def file?(path)
|
|
@@ -34,6 +35,16 @@ module Raindown
|
|
|
34
35
|
EXTENSIONS.include?(File.extname(path).downcase)
|
|
35
36
|
end
|
|
36
37
|
|
|
38
|
+
# Whether the front matter has "raindown: true". Front matter that isn't valid YAML fails when the file renders,
|
|
39
|
+
# so here it only means no.
|
|
40
|
+
def front_matter?(content)
|
|
41
|
+
return false unless content&.start_with?('---')
|
|
42
|
+
|
|
43
|
+
FrontMatter.parse(content).first[:raindown] == true
|
|
44
|
+
rescue Psych::Exception
|
|
45
|
+
false
|
|
46
|
+
end
|
|
47
|
+
|
|
37
48
|
# Wrap each bare directive in Antlers delimiters and close its block, leaving code and front matter as-is.
|
|
38
49
|
def expand(content)
|
|
39
50
|
lines = content.lines
|
data/lib/raindown/document.rb
CHANGED
|
@@ -32,8 +32,8 @@ module Raindown
|
|
|
32
32
|
new(markdown:, bare:)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
# Raindown files read bare directives
|
|
36
|
-
# like with Nodes.load(path), the same as when the file renders.
|
|
35
|
+
# Raindown files read bare directives, as do Markdown files with "raindown: true" front matter.
|
|
36
|
+
# A project's own nodes are only directives once they're loaded, like with Nodes.load(path), the same as when the file renders.
|
|
37
37
|
def self.read(path)
|
|
38
38
|
new(markdown: File.read(path, encoding: Encoding::UTF_8), bare: BareDirectives.file?(path))
|
|
39
39
|
end
|
|
@@ -41,7 +41,7 @@ module Raindown
|
|
|
41
41
|
def initialize(markdown:, bare: false)
|
|
42
42
|
@markdown = markdown
|
|
43
43
|
@lines = markdown.lines
|
|
44
|
-
@bare = bare
|
|
44
|
+
@bare = bare || BareDirectives.front_matter?(markdown)
|
|
45
45
|
end
|
|
46
46
|
|
|
47
47
|
# The headings in the order they appear, with their source text, like "Notes for {name}" before it's rendered.
|
|
@@ -26,7 +26,7 @@ module Raindown
|
|
|
26
26
|
FETCHED = /\A {0,3}<!-- raindown:fetched [^\n]*? -->[ \t]*$/
|
|
27
27
|
|
|
28
28
|
def self.rewrite(content:, path: nil, bare: false, execute: false, **)
|
|
29
|
-
new(content:, bare: BareDirectives.enabled?(path:, bare:), execute:).rewrite
|
|
29
|
+
new(content:, bare: BareDirectives.enabled?(path:, content:, bare:), execute:).rewrite
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
def initialize(content:, bare: false, execute: false, only: nil)
|
data/lib/raindown.rb
CHANGED
|
@@ -47,6 +47,8 @@ module Raindown
|
|
|
47
47
|
# Directives like "toc:" export to HTML as bold or comments depending on hide_directives config.
|
|
48
48
|
# Code blocks are highlighted, unless highlight_code is false for a site that highlights code in the browser.
|
|
49
49
|
def render(markdown:, metadata: NoMetadata, bare: false, hide_directives: false, highlight_code: true)
|
|
50
|
+
bare ||= BareDirectives.front_matter?(markdown)
|
|
51
|
+
|
|
50
52
|
highlighting(highlight_code) do
|
|
51
53
|
Fragments.collect do
|
|
52
54
|
# Components' HTML goes back in, then their headings get unique ids, before nodes like the TOC see it.
|
data/lib/version.rb
CHANGED