raindown 0.24.0 → 0.25.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/bare_directives.rb +5 -3
- data/lib/raindown/editing.rb +2 -2
- data/lib/raindown/edition.rb +31 -12
- data/lib/raindown/features.rb +121 -0
- data/lib/raindown/node_injector.rb +3 -1
- data/lib/raindown/nodes.rb +10 -44
- data/lib/raindown/pre_renderer.rb +4 -4
- data/lib/raindown/project_nodes.rb +2 -0
- data/lib/raindown/projects.rb +3 -3
- data/lib/raindown/rasters.rb +1 -0
- data/lib/raindown/rewriter.rb +6 -7
- data/lib/raindown/ruby_nodes.rb +40 -0
- data/lib/raindown/table/table_file.rb +4 -0
- data/lib/raindown.rb +1 -2
- data/lib/version.rb +1 -1
- metadata +3 -2
- data/lib/elements.rb +0 -45
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a4a2ea73463494d27cc4f25837dfd35c0032c2a28ba9de81c5848e57b0c52b9
|
|
4
|
+
data.tar.gz: 5d7418c4629ad422ce4a52f7b80a22be222ec8b99b363f7d68fa0c0537b41f6a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a34bbfa7f7bc80d7847cfea11d77c3ceec2f52cdb922f325eb58cfb220beef4eee83ec195528c52dd1ed6c3cb23fc96971cfd6149afbf69a6aa4b4fd21841867
|
|
7
|
+
data.tar.gz: e85a776381def36dee2d5e7befe65ccbd1f714958391ba320ad40421f891739bb4bf6b23bd369b04ade1450d6b1c3b2e3de58b8a7a40be33d6c38c3990c6337b
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'code_blocks'
|
|
4
4
|
require_relative 'directives'
|
|
5
|
-
require_relative '
|
|
5
|
+
require_relative 'edition'
|
|
6
6
|
require_relative 'front_matter'
|
|
7
7
|
|
|
8
8
|
module Raindown
|
|
@@ -68,8 +68,10 @@ module Raindown
|
|
|
68
68
|
# Returns the index of the last line it handled. That's the directive itself, so the lines it holds
|
|
69
69
|
# are expanded too, and a bare directive inside it closes before it does.
|
|
70
70
|
def expand_line(lines, index)
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
Raindown.edition.plugs(:schema_block).each do |schemas|
|
|
72
|
+
schema = schemas.at(lines, index, bare: true)
|
|
73
|
+
return expand_schema(lines, index, schema) if schema
|
|
74
|
+
end
|
|
73
75
|
|
|
74
76
|
match = lines[index].match(LINE)
|
|
75
77
|
return index unless match
|
data/lib/raindown/editing.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Raindown
|
|
|
18
18
|
# Without commonmark, it's Markdown, for the editor to render itself.
|
|
19
19
|
def render_markdown(markdown, path:, bare: false, commonmark: true)
|
|
20
20
|
Nodes.load(path)
|
|
21
|
-
Raindown.render(markdown:, metadata:
|
|
21
|
+
Raindown.render(markdown:, metadata: Raindown.edition.metadata(path), bare: bare || BareDirectives.file?(path), commonmark:,
|
|
22
22
|
**Config.render_options(path))
|
|
23
23
|
end
|
|
24
24
|
|
|
@@ -27,7 +27,7 @@ module Raindown
|
|
|
27
27
|
def rewrite_markdown(markdown, path:, bare: false, execute: false, actions: [])
|
|
28
28
|
load_errors = Nodes.load(path)
|
|
29
29
|
markdown = acted(markdown, actions, path:, bare:)
|
|
30
|
-
rewrite = Rewriter.rewrite(content: markdown, path:, bare:, execute:, metadata:
|
|
30
|
+
rewrite = Rewriter.rewrite(content: markdown, path:, bare:, execute:, metadata: Raindown.edition.metadata(path))
|
|
31
31
|
failures = rewrite.failures.map { "Endpoint check failed: #{it}" }
|
|
32
32
|
{ output: rewrite.content, warnings: load_errors + failures + rewrite.problems }
|
|
33
33
|
end
|
data/lib/raindown/edition.rb
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative 'features'
|
|
4
|
+
|
|
3
5
|
module Raindown
|
|
4
|
-
# What a product built on Raindown does with it, set before any note's written
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# written.
|
|
6
|
+
# What a product built on Raindown does with it, set before any note's written, as the features it has: Raindown
|
|
7
|
+
# itself, with all of them, and a project's components in its .raindown folder, or Components, the Obsidian plugin
|
|
8
|
+
# for beginners, with only Markdown Components, in a vault's Components folder, which Obsidian shows, so the rest of a
|
|
9
|
+
# note, like a table, stays as it's written. Only the features an edition has load.
|
|
9
10
|
class Edition
|
|
10
11
|
attr_reader :folder
|
|
11
12
|
|
|
12
|
-
def initialize(folder:,
|
|
13
|
+
def initialize(folder:, features:)
|
|
13
14
|
@folder = folder
|
|
14
|
-
@
|
|
15
|
+
@features = Features[*features]
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# What its features have of a kind, like components, loaded the first time they're asked for, and kept, as some are
|
|
19
|
+
# asked for on each line.
|
|
20
|
+
def plugs(key)
|
|
21
|
+
@plugs ||= {}
|
|
22
|
+
return @plugs[key] if @plugs.key?(key)
|
|
23
|
+
return @plugs[key] = [] unless @features.plugs.key?(key)
|
|
24
|
+
|
|
25
|
+
@plugs[key] = @features[key].to_a
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# The notes list: lists and wiki links link to, beside the file, when it has them, or none.
|
|
29
|
+
def metadata(path)
|
|
30
|
+
pages = plugs(:pages).first
|
|
31
|
+
return NoMetadata unless pages
|
|
32
|
+
|
|
33
|
+
pages.for(path)
|
|
15
34
|
end
|
|
16
35
|
|
|
17
|
-
#
|
|
18
|
-
def
|
|
19
|
-
@
|
|
36
|
+
# Its write-in nodes' and endpoints' lexemes and nodes, for Antlers.
|
|
37
|
+
def elements
|
|
38
|
+
@features[:lexeme, :node]
|
|
20
39
|
end
|
|
21
40
|
|
|
22
|
-
FULL = new(folder: '.raindown',
|
|
23
|
-
COMPONENTS = new(folder: 'Components',
|
|
41
|
+
FULL = new(folder: '.raindown', features: %i[write_in code_components markdown_components built_ins pages endpoints schemas tables])
|
|
42
|
+
COMPONENTS = new(folder: 'Components', features: %i[write_in markdown_components])
|
|
24
43
|
end
|
|
25
44
|
|
|
26
45
|
class << self
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'plugs'
|
|
4
|
+
|
|
5
|
+
module Raindown
|
|
6
|
+
# What an edition can have, each loading its files the first time an edition that has it asks for it, so one that
|
|
7
|
+
# hasn't never loads them. Components are found in the order they're here: Ruby, then JavaScript, then Markdown.
|
|
8
|
+
class Features
|
|
9
|
+
include Plugs
|
|
10
|
+
|
|
11
|
+
# Write-in nodes, in <{ }>, like <{ Card }>, <{ :toc }> or <{ Card: }>...<{ :Card }>, rendered in the template pass.
|
|
12
|
+
plug(:write_in) do
|
|
13
|
+
plug(:lexeme) do
|
|
14
|
+
lazy do
|
|
15
|
+
require_relative '../lexemes/node_lexeme'
|
|
16
|
+
NodeLexeme
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# A list: block loops over its files, so it comes before other nodes' blocks.
|
|
21
|
+
plug(:node) do
|
|
22
|
+
lazy do
|
|
23
|
+
require_relative '../nodes/list_node'
|
|
24
|
+
ListNode
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
plug(:node) do
|
|
29
|
+
lazy do
|
|
30
|
+
require_relative '../nodes/write_in_node'
|
|
31
|
+
WriteInNode
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
plug(:node) do
|
|
36
|
+
lazy do
|
|
37
|
+
require_relative '../nodes/write_in_node'
|
|
38
|
+
SoloWriteInNode
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
plug(:code_components) do
|
|
44
|
+
plug(:components) do
|
|
45
|
+
lazy do
|
|
46
|
+
require_relative 'ruby_nodes'
|
|
47
|
+
RubyNodes
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
plug(:components) do
|
|
52
|
+
lazy do
|
|
53
|
+
require_relative 'js/js_nodes'
|
|
54
|
+
JSNodes
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
plug(:markdown_components) do
|
|
60
|
+
plug(:components) do
|
|
61
|
+
lazy do
|
|
62
|
+
require_relative 'markdown_nodes'
|
|
63
|
+
MarkdownNodes
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# Raindown's own nodes, like toc:, each loaded the first time a note names it.
|
|
69
|
+
plug(:built_ins) do
|
|
70
|
+
lazy { Nodes::BUILT_INS }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# A project's notes, which list: lists and wiki links link to, listed with Dirload.
|
|
74
|
+
plug(:pages) do
|
|
75
|
+
lazy { Pages }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
plug(:endpoints) do
|
|
79
|
+
plug(:endpoint_runner) do
|
|
80
|
+
lazy do
|
|
81
|
+
require_relative 'endpoint/endpoint_runner'
|
|
82
|
+
EndpointRunner
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
plug(:lexeme) do
|
|
87
|
+
lazy do
|
|
88
|
+
require_relative '../lexemes/endpoint_lexeme'
|
|
89
|
+
EndpointLexeme
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
plug(:node) do
|
|
94
|
+
lazy do
|
|
95
|
+
require_relative '../nodes/endpoint_node'
|
|
96
|
+
EndpointNode
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Schemas, like schema: User, which endpoints check responses against.
|
|
102
|
+
plug(:schemas) do
|
|
103
|
+
plug(:schema_block) do
|
|
104
|
+
lazy do
|
|
105
|
+
require_relative 'endpoint/schema_block'
|
|
106
|
+
SchemaBlock
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Lining up tables' columns as a note's written back.
|
|
112
|
+
plug(:tables) do
|
|
113
|
+
plug(:table_formatter) do
|
|
114
|
+
lazy do
|
|
115
|
+
require_relative 'table/table_formatter'
|
|
116
|
+
TableFormatter
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
@@ -78,7 +78,9 @@ module Raindown
|
|
|
78
78
|
# costs about as much as a node. So they see the document as it was before the blocks wrote, not what the nodes
|
|
79
79
|
# below them just wrote. A host that can't be asked leaves each to be asked alone, to say why in its place.
|
|
80
80
|
def written_ahead(lines, blocks)
|
|
81
|
-
ahead = blocks.select { it[:node].
|
|
81
|
+
ahead = blocks.select { it[:node].respond_to?(:call_for) }
|
|
82
|
+
return {} if ahead.empty?
|
|
83
|
+
|
|
82
84
|
calls = ahead.map { it[:node].call_for(:rewrite, context_of(lines, it)) }
|
|
83
85
|
ahead.map { it[:open] }.zip(JSNodes.call(calls, metadata: @metadata)).to_h
|
|
84
86
|
rescue JSNodes::Error
|
data/lib/raindown/nodes.rb
CHANGED
|
@@ -2,10 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative 'edition'
|
|
4
4
|
require_relative 'fragments'
|
|
5
|
-
require_relative 'js/js_nodes'
|
|
6
|
-
require_relative 'markdown_nodes'
|
|
7
5
|
require_relative 'node'
|
|
8
6
|
require_relative 'problem'
|
|
7
|
+
require_relative 'services'
|
|
9
8
|
require_relative 'stat'
|
|
10
9
|
|
|
11
10
|
module Raindown
|
|
@@ -38,8 +37,8 @@ module Raindown
|
|
|
38
37
|
|
|
39
38
|
# Loads the .raindown folder beside the file or in the nearest directory above it, or the edition's own, like
|
|
40
39
|
# Components', once per process, and gives why any of its files couldn't be loaded, like ".raindown/stars.rb:3:
|
|
41
|
-
# syntax errors found". Each file loads on its own, so one that can't be leaves the others loaded.
|
|
42
|
-
#
|
|
40
|
+
# syntax errors found". Each file loads on its own, so one that can't be leaves the others loaded. Only the kinds of
|
|
41
|
+
# components the edition has load, like only Markdown Components in Components.
|
|
43
42
|
def load(path)
|
|
44
43
|
folder = find_folder(File.dirname(File.expand_path(path)))
|
|
45
44
|
return [] if folder.nil?
|
|
@@ -49,39 +48,8 @@ module Raindown
|
|
|
49
48
|
load_errors[folder] = load_folder(folder)
|
|
50
49
|
end
|
|
51
50
|
|
|
52
|
-
# The folder's components loaded, with why any couldn't be: only its Markdown Components in an edition that isn't
|
|
53
|
-
# full.
|
|
54
51
|
def load_folder(folder)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
load_ruby(folder) + JSNodes.load(folder) + MarkdownNodes.load(folder)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# Dirload's steps, for the folder's Ruby files, as dirload(folder) takes them, a file that fails one being left out
|
|
61
|
-
# of the next, and why each failed.
|
|
62
|
-
def load_ruby(folder)
|
|
63
|
-
require 'lownode'
|
|
64
|
-
require 'dirload'
|
|
65
|
-
files = Dirload.file_paths(absolute_path: folder).map { [it, Dirload.find_adapter(file_path: it)] }
|
|
66
|
-
errors = {}
|
|
67
|
-
%i[mapload preload evaluate].each do |step|
|
|
68
|
-
files.each do |file, adapter|
|
|
69
|
-
next if adapter.nil? || errors.key?(file)
|
|
70
|
-
|
|
71
|
-
adapter.public_send(step, file_path: file)
|
|
72
|
-
rescue StandardError, ScriptError => e
|
|
73
|
-
errors[file] = e.message
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
errors.map { |file, message| load_error(folder, file, message) }
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Why a file couldn't be loaded, by its path from the project, with its line, when the error has it.
|
|
80
|
-
def load_error(folder, file, message)
|
|
81
|
-
listed = file.delete_prefix("#{File.dirname(folder)}/")
|
|
82
|
-
return "#{listed}#{message.delete_prefix(file)}" if message.start_with?("#{file}:")
|
|
83
|
-
|
|
84
|
-
"#{listed}: #{message}"
|
|
52
|
+
Raindown.edition.plugs(:components).flat_map { it.load(folder) }
|
|
85
53
|
end
|
|
86
54
|
|
|
87
55
|
def load_errors
|
|
@@ -104,19 +72,17 @@ module Raindown
|
|
|
104
72
|
@loaded ||= []
|
|
105
73
|
end
|
|
106
74
|
|
|
107
|
-
# The node class a block names, when it's loaded, and Raindown's own,
|
|
75
|
+
# The node class a block names, when it's loaded, and Raindown's own, when the edition has them.
|
|
108
76
|
def node_class(name)
|
|
109
|
-
|
|
77
|
+
built_in = Raindown.edition.plugs(:built_ins).reduce({}, :merge)[name]
|
|
78
|
+
return loaded_class(name) unless built_in
|
|
110
79
|
|
|
111
|
-
loaded_class(
|
|
80
|
+
loaded_class(built_in) || Raindown.const_get(built_in)
|
|
112
81
|
end
|
|
113
82
|
|
|
114
|
-
#
|
|
83
|
+
# The first of the edition's kinds of components, in order, with a node of the name: Ruby, JavaScript, then Markdown.
|
|
115
84
|
def loaded_class(name)
|
|
116
|
-
|
|
117
|
-
return klass if node?(klass)
|
|
118
|
-
|
|
119
|
-
JSNodes.node_class(name) || MarkdownNodes.node_class(name)
|
|
85
|
+
Raindown.edition.plugs(:components).lazy.filter_map { it.node_class(name) }.first
|
|
120
86
|
end
|
|
121
87
|
|
|
122
88
|
# A LowNode, or one of Raindown's own nodes, that writes Markdown. In an app, LowNodes are also routes and pages,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'antlers'
|
|
4
|
-
require_relative '
|
|
4
|
+
require_relative 'edition'
|
|
5
5
|
require_relative 'bare_directives'
|
|
6
6
|
require_relative 'code'
|
|
7
7
|
require_relative 'code_blocks'
|
|
@@ -55,9 +55,9 @@ module Raindown
|
|
|
55
55
|
# Antlers strips the whitespace around a template, which can be Markdown, like an indented code block.
|
|
56
56
|
leading = template[/\A\s*/]
|
|
57
57
|
trailing = template[/\s*\z/]
|
|
58
|
-
# Write-in nodes and endpoints render here too, where loop variables are in scope, and
|
|
59
|
-
# fragments.
|
|
60
|
-
elements = Antlers::Elements[:html, :var, :if, :for] +
|
|
58
|
+
# Write-in nodes and endpoints, when the edition has them, render here too, where loop variables are in scope, and
|
|
59
|
+
# keep their HTML as fragments.
|
|
60
|
+
elements = Antlers::Elements[:html, :var, :if, :for] + Raindown.edition.elements
|
|
61
61
|
rendered = Antlers.render(ast: Antlers.ast(template:, elements:), current_binding: variables.binding, context:)
|
|
62
62
|
|
|
63
63
|
"#{leading}#{rendered}#{trailing}"
|
data/lib/raindown/projects.rb
CHANGED
|
@@ -11,8 +11,6 @@ module Raindown
|
|
|
11
11
|
module Projects
|
|
12
12
|
# Folders of dependencies, builds and tooling, which aren't searched for projects or watched, nor are hidden folders.
|
|
13
13
|
IGNORED = %w[node_modules vendor tmp pkg build dist coverage].freeze
|
|
14
|
-
# Ruby nodes and JavaScript Components.
|
|
15
|
-
NODE_EXTENSIONS = ['.rb', '.rbx', *JSNodes::EXTENSIONS].freeze
|
|
16
14
|
VAULT_FOLDER = '.obsidian'
|
|
17
15
|
|
|
18
16
|
module_function
|
|
@@ -82,8 +80,10 @@ module Raindown
|
|
|
82
80
|
|
|
83
81
|
# Whether a file is one of a project's own nodes, which load when its watcher starts.
|
|
84
82
|
def node?(path, root:)
|
|
83
|
+
require_relative 'js/js_nodes'
|
|
84
|
+
require_relative 'markdown_nodes'
|
|
85
85
|
File.expand_path(path).start_with?(File.join(root, Nodes::FOLDER, '')) &&
|
|
86
|
-
(
|
|
86
|
+
(['.rb', '.rbx', *JSNodes::EXTENSIONS].include?(File.extname(path)) || MarkdownNodes.file?(path))
|
|
87
87
|
end
|
|
88
88
|
|
|
89
89
|
# The roots that aren't inside another of them, as a project's code includes the projects inside it.
|
data/lib/raindown/rasters.rb
CHANGED
data/lib/raindown/rewriter.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'node_injector'
|
|
4
|
-
require_relative 'endpoint/endpoint_runner'
|
|
5
|
-
require_relative 'table/table_formatter'
|
|
6
4
|
require_relative 'utils'
|
|
7
5
|
|
|
8
6
|
module Raindown
|
|
@@ -22,14 +20,15 @@ module Raindown
|
|
|
22
20
|
def rewrite(content:, path:, bare: false, execute: false, metadata: NoMetadata)
|
|
23
21
|
injector = NodeInjector.new(content:, path:, bare:, metadata:)
|
|
24
22
|
injected = injector.call
|
|
25
|
-
return Rewrite.new(original: content, content: injected, failures: [], problems: injector.problems) unless Raindown.edition.full?
|
|
26
|
-
|
|
27
23
|
# Only a file naming an endpoint has one to run, so the rest aren't read again for one.
|
|
28
24
|
if injected.include?('endpoint:')
|
|
29
|
-
|
|
25
|
+
runner = Raindown.edition.plugs(:endpoint_runner).first
|
|
26
|
+
endpoints = runner&.new(content: injected, path:, bare: BareDirectives.enabled?(path:, content: injected, bare:), execute:)
|
|
27
|
+
end
|
|
28
|
+
lined_up = Raindown.edition.plugs(:table_formatter).reduce(endpoints&.rewrite || injected) do |text, formatter|
|
|
29
|
+
formatter.rewrite(content: text)
|
|
30
30
|
end
|
|
31
|
-
Rewrite.new(original: content, content:
|
|
32
|
-
failures: Array(endpoints&.failures), problems: injector.problems)
|
|
31
|
+
Rewrite.new(original: content, content: lined_up, failures: Array(endpoints&.failures), problems: injector.problems)
|
|
33
32
|
end
|
|
34
33
|
|
|
35
34
|
# Writes the file only when it changed.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Raindown
|
|
4
|
+
# A project's nodes in Ruby, in its .raindown folder, loaded with Dirload, which define LowNodes as constants.
|
|
5
|
+
module RubyNodes
|
|
6
|
+
module_function
|
|
7
|
+
|
|
8
|
+
# Dirload's steps, for the folder's Ruby files, as dirload(folder) takes them, a file that fails one being left out
|
|
9
|
+
# of the next, and why each failed.
|
|
10
|
+
def load(folder)
|
|
11
|
+
require 'lownode'
|
|
12
|
+
require 'dirload'
|
|
13
|
+
files = Dirload.file_paths(absolute_path: folder).map { [it, Dirload.find_adapter(file_path: it)] }
|
|
14
|
+
errors = {}
|
|
15
|
+
%i[mapload preload evaluate].each do |step|
|
|
16
|
+
files.each do |file, adapter|
|
|
17
|
+
next if adapter.nil? || errors.key?(file)
|
|
18
|
+
|
|
19
|
+
adapter.public_send(step, file_path: file)
|
|
20
|
+
rescue StandardError, ScriptError => e
|
|
21
|
+
errors[file] = e.message
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
errors.map { |file, message| load_error(folder, file, message) }
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Why a file couldn't be loaded, by its path from the project, with its line, when the error has it.
|
|
28
|
+
def load_error(folder, file, message)
|
|
29
|
+
listed = file.delete_prefix("#{File.dirname(folder)}/")
|
|
30
|
+
return "#{listed}#{message.delete_prefix(file)}" if message.start_with?("#{file}:")
|
|
31
|
+
|
|
32
|
+
"#{listed}: #{message}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def node_class(name)
|
|
36
|
+
klass = Object.const_get(name) if name.match?(/\A[A-Z]/) && Object.const_defined?(name)
|
|
37
|
+
klass if Nodes.node?(klass)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
# FileUtils makes a new file's folders. It's loaded with a table:, rather than when one's made, so the Obsidian plugin's
|
|
4
|
+
# trace, which writes back tables but needn't make one, packs it.
|
|
5
|
+
require 'fileutils'
|
|
6
|
+
|
|
3
7
|
# Loaded when first used, as it loads strscan, a native extension, which slows a packed executable's start.
|
|
4
8
|
autoload :CSV, 'csv'
|
|
5
9
|
|
data/lib/raindown.rb
CHANGED
|
@@ -11,7 +11,6 @@ module Unicode
|
|
|
11
11
|
autoload :DisplayWidth, 'unicode/display_width'
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
require_relative 'elements'
|
|
15
14
|
require_relative 'raindown/bare_directives'
|
|
16
15
|
require_relative 'raindown/code'
|
|
17
16
|
require_relative 'raindown/config'
|
|
@@ -24,7 +23,6 @@ require_relative 'raindown/node_blocks'
|
|
|
24
23
|
require_relative 'raindown/outdent'
|
|
25
24
|
require_relative 'raindown/pages/pages'
|
|
26
25
|
require_relative 'raindown/pre_renderer'
|
|
27
|
-
require_relative 'raindown/table/table_formatter'
|
|
28
26
|
require_relative 'raindown/utils'
|
|
29
27
|
require_relative 'raindown/variables'
|
|
30
28
|
require_relative 'raindown/wiki_links'
|
|
@@ -116,6 +114,7 @@ module Raindown
|
|
|
116
114
|
def commonmark(markdown)
|
|
117
115
|
return markdown unless commonmark?
|
|
118
116
|
|
|
117
|
+
require_relative 'raindown/table/table_formatter'
|
|
119
118
|
doc = parse_markdown(hide_directives(markdown: TableFormatter.gfm(markdown)))
|
|
120
119
|
preserve_code(doc:)
|
|
121
120
|
|
data/lib/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: raindown
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.25.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- maedi
|
|
@@ -202,7 +202,6 @@ extensions: []
|
|
|
202
202
|
extra_rdoc_files: []
|
|
203
203
|
files:
|
|
204
204
|
- bin/raindown
|
|
205
|
-
- lib/elements.rb
|
|
206
205
|
- lib/lexemes/endpoint_lexeme.rb
|
|
207
206
|
- lib/lexemes/node_lexeme.rb
|
|
208
207
|
- lib/nodes/endpoint_node.rb
|
|
@@ -237,6 +236,7 @@ files:
|
|
|
237
236
|
- lib/raindown/endpoint/endpoint_runner.rb
|
|
238
237
|
- lib/raindown/endpoint/endpoint_variables.rb
|
|
239
238
|
- lib/raindown/endpoint/schema_block.rb
|
|
239
|
+
- lib/raindown/features.rb
|
|
240
240
|
- lib/raindown/fragments.rb
|
|
241
241
|
- lib/raindown/front_matter.rb
|
|
242
242
|
- lib/raindown/gitignore.rb
|
|
@@ -271,6 +271,7 @@ files:
|
|
|
271
271
|
- lib/raindown/projects.rb
|
|
272
272
|
- lib/raindown/rasters.rb
|
|
273
273
|
- lib/raindown/rewriter.rb
|
|
274
|
+
- lib/raindown/ruby_nodes.rb
|
|
274
275
|
- lib/raindown/scene.rb
|
|
275
276
|
- lib/raindown/server.rb
|
|
276
277
|
- lib/raindown/services.rb
|
data/lib/elements.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'plugs'
|
|
4
|
-
|
|
5
|
-
module Raindown
|
|
6
|
-
class Elements
|
|
7
|
-
include Plugs
|
|
8
|
-
|
|
9
|
-
# Write-in nodes, in <{ }>, like <{ Card }>, <{ :toc }> or <{ Card: }>...<{ :Card }>, rendered in the template pass.
|
|
10
|
-
plug(:write_in) do
|
|
11
|
-
plug(:lexeme) do
|
|
12
|
-
require_relative 'lexemes/node_lexeme'
|
|
13
|
-
NodeLexeme
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
# A list: block loops over its files, so it comes before other nodes' blocks.
|
|
17
|
-
plug(:node) do
|
|
18
|
-
require_relative 'nodes/list_node'
|
|
19
|
-
ListNode
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
plug(:node) do
|
|
23
|
-
require_relative 'nodes/write_in_node'
|
|
24
|
-
WriteInNode
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
plug(:node) do
|
|
28
|
-
require_relative 'nodes/write_in_node'
|
|
29
|
-
SoloWriteInNode
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
plug(:endpoint) do
|
|
34
|
-
plug(:lexeme) do
|
|
35
|
-
require_relative 'lexemes/endpoint_lexeme'
|
|
36
|
-
EndpointLexeme
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
plug(:node) do
|
|
40
|
-
require_relative 'nodes/endpoint_node'
|
|
41
|
-
EndpointNode
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|