raindown 0.13.0 → 0.15.0

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.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/lib/elements.rb +12 -25
  3. data/lib/lexemes/node_lexeme.rb +37 -0
  4. data/lib/nodes/list_node.rb +22 -25
  5. data/lib/nodes/write_in_node.rb +95 -0
  6. data/lib/raindown/bare_directives.rb +1 -1
  7. data/lib/raindown/chart/chart.rb +1 -1
  8. data/lib/raindown/cli.rb +2 -0
  9. data/lib/raindown/context.rb +19 -0
  10. data/lib/raindown/directives.rb +1 -1
  11. data/lib/raindown/fragments.rb +6 -1
  12. data/lib/raindown/js/host.mjs +2 -2
  13. data/lib/raindown/js/js_nodes.rb +4 -4
  14. data/lib/raindown/list.rb +31 -0
  15. data/lib/raindown/markdown_nodes.rb +3 -2
  16. data/lib/raindown/node.rb +10 -2
  17. data/lib/raindown/node_blocks.rb +27 -21
  18. data/lib/raindown/node_injector.rb +1 -1
  19. data/lib/raindown/nodes.rb +60 -22
  20. data/lib/raindown/pages.rb +8 -4
  21. data/lib/raindown/pre_renderer.rb +13 -10
  22. data/lib/raindown/projects.rb +24 -4
  23. data/lib/raindown/rewriter.rb +1 -1
  24. data/lib/raindown/stat.rb +1 -1
  25. data/lib/raindown/table/markdown_table.rb +11 -3
  26. data/lib/raindown/table/table.rb +92 -12
  27. data/lib/raindown/table/table_formulas.rb +50 -0
  28. data/lib/raindown/table/written_table.rb +68 -0
  29. data/lib/raindown/toc.rb +2 -2
  30. data/lib/raindown/tui/navigator/commands.rb +7 -1
  31. data/lib/raindown/watcher/changes.rb +5 -3
  32. data/lib/raindown/watcher/supervisor.rb +1 -1
  33. data/lib/raindown/wiki_links.rb +1 -1
  34. data/lib/raindown.rb +9 -14
  35. data/lib/version.rb +1 -1
  36. metadata +11 -8
  37. data/lib/lexemes/list_lexeme.rb +0 -32
  38. data/lib/nodes/component_nodes.rb +0 -38
  39. data/lib/raindown/files.rb +0 -22
  40. /data/lib/raindown/{table_formatter.rb → table/table_formatter.rb} +0 -0
@@ -19,10 +19,12 @@ module Raindown
19
19
  Listen.to(directory, ignore: IGNORE) { |modified, added, removed| yield(modified + added + removed) }
20
20
  end
21
21
 
22
- # The changes among the paths, by the project each is in, the nearest one above it, or else the root, when there is
23
- # one, leaving out files that are neither nodes nor Markdown, or are in ignored folders.
24
- def self.changes(paths, root: nil)
22
+ # The changes among the paths in the directory, by the project each is in, the nearest one above it, or else the
23
+ # root, when there is one, leaving out files that are neither nodes nor Markdown, or are in ignored folders or vaults.
24
+ def self.changes(paths, directory:, root: nil)
25
25
  paths.filter_map do |path|
26
+ next if Projects.vault_below?(path, directory)
27
+
26
28
  project = Projects.root(path) || root || next
27
29
  next Change.new(root: project, path:, nodes: true) if Projects.node?(path, root: project)
28
30
 
@@ -42,7 +42,7 @@ module Raindown
42
42
  # endpoint's request with -x, only holds up its own project. Without fork, the projects share this process, so
43
43
  # they're taken in turn.
44
44
  def handle(paths)
45
- Watcher.changes(paths).each do |change|
45
+ Watcher.changes(paths, directory:).each do |change|
46
46
  next unless change.nodes? || change.saved?
47
47
  next take(change) unless fork?
48
48
 
@@ -5,7 +5,7 @@ require_relative 'front_matter'
5
5
 
6
6
  module Raindown
7
7
  # Obsidian's links between notes, which render as Markdown links to the file they name, by its path in the project,
8
- # like files: links, while the file keeps them as they are:
8
+ # like list: links, while the file keeps them as they are:
9
9
  # [[Reading list]] [Reading list](<notes/Reading list.md>)
10
10
  # [[Reading list|books]] [books](<notes/Reading list.md>)
11
11
  # [[Reading list#To read]] [Reading list > To read](<notes/Reading list.md#to-read>)
data/lib/raindown.rb CHANGED
@@ -8,6 +8,7 @@ require_relative 'elements'
8
8
  require_relative 'raindown/bare_directives'
9
9
  require_relative 'raindown/code'
10
10
  require_relative 'raindown/config'
11
+ require_relative 'raindown/context'
11
12
  require_relative 'raindown/directives'
12
13
  require_relative 'raindown/fragments'
13
14
  require_relative 'raindown/front_matter'
@@ -32,7 +33,7 @@ module Raindown
32
33
  # Without highlighting, code blocks are left for the browser to highlight, like <pre><code class="language-ruby">.
33
34
  UNHIGHLIGHTED_OPTIONS = { render: { **HTML_OPTIONS[:render], github_pre_lang: false } }.freeze
34
35
 
35
- # Stands in for an app's metadata when there isn't any, so list: and files: list nothing.
36
+ # Stands in for an app's metadata when there isn't any, so list: lists nothing.
36
37
  module NoMetadata
37
38
  def self.list(**) = []
38
39
  end
@@ -49,13 +50,12 @@ module Raindown
49
50
  # Bare directives like "toc:" show in bold in the HTML, and the rest stay hidden, as comments.
50
51
  # Code blocks are highlighted, unless highlight_code is false for a site that highlights code in the browser.
51
52
  def render(markdown:, metadata: NoMetadata, bare: false, highlight_code: true)
52
- bare ||= BareDirectives.front_matter?(markdown)
53
+ context = Context.new(document: markdown, metadata:, bare: bare || BareDirectives.front_matter?(markdown))
53
54
 
54
55
  highlighting(highlight_code) do
55
56
  Fragments.collect do
56
57
  # Components' HTML goes back in, then their headings get unique ids, before nodes like the TOC see it.
57
- html = assembled(markdown:, metadata:, bare:)
58
- html = Nodes.render_placeholders(html, document: markdown, metadata:, bare:, html:)
58
+ html = Nodes.render_placeholders(assembled(context), context)
59
59
 
60
60
  Directives.render("#{html.chomp}\n")
61
61
  end
@@ -77,15 +77,14 @@ module Raindown
77
77
  end
78
78
 
79
79
  # The document's HTML with its components' HTML put back, and unique heading ids.
80
- def assembled(markdown:, metadata: NoMetadata, bare: false)
81
- HeadingIds.unique(Fragments.fill(html(markdown:, variables: variables(markdown:), metadata:, bare:)))
80
+ def assembled(context)
81
+ HeadingIds.unique(Fragments.fill(html(context)))
82
82
  end
83
83
 
84
84
  # The document's HTML from Commonmarker, after nodes and the template pass, with components as fragments.
85
- def html(markdown:, variables:, metadata: NoMetadata, bare: false)
86
- markdown = NodeBlocks.to_rendered(markdown.dup.force_encoding('UTF-8'), metadata:, bare:)
87
- markdown = WikiLinks.to_markdown(markdown, metadata:)
88
- commonmark(PreRenderer.render(markdown, variables:, metadata:, bare:))
85
+ def html(context)
86
+ markdown = WikiLinks.to_markdown(NodeBlocks.to_rendered(context), metadata: context.metadata)
87
+ commonmark(PreRenderer.render(markdown, variables: context.variables, context:))
89
88
  end
90
89
 
91
90
  # Markdown to HTML, like a document's or a component's slot.
@@ -103,10 +102,6 @@ module Raindown
103
102
  doc.to_html(options: UNHIGHLIGHTED_OPTIONS, plugins: { syntax_highlighter: nil })
104
103
  end
105
104
 
106
- def variables(markdown:)
107
- Variables.new(FrontMatter.parse(markdown).first)
108
- end
109
-
110
105
  # Commonmarker escapes directives, so they're hidden in HTML comments until it's done.
111
106
  def hide_directives(markdown:)
112
107
  markdown.gsub('<{', '<!-- ANTLERS').gsub('}>', 'ANTLERS -->').force_encoding('UTF-8')
data/lib/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raindown
4
- VERSION = '0.13.0'
4
+ VERSION = '0.15.0'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raindown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - maedi
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-11-05 00:00:00.000000000 Z
10
+ date: 2026-11-06 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: antlers
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: 1.4.0
18
+ version: 1.5.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 1.4.0
25
+ version: 1.5.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: commonmarker
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -204,10 +204,10 @@ files:
204
204
  - bin/raindown
205
205
  - lib/elements.rb
206
206
  - lib/lexemes/endpoint_lexeme.rb
207
- - lib/lexemes/list_lexeme.rb
208
- - lib/nodes/component_nodes.rb
207
+ - lib/lexemes/node_lexeme.rb
209
208
  - lib/nodes/endpoint_node.rb
210
209
  - lib/nodes/list_node.rb
210
+ - lib/nodes/write_in_node.rb
211
211
  - lib/raindown.rb
212
212
  - lib/raindown/actions.rb
213
213
  - lib/raindown/bare_directives.rb
@@ -223,6 +223,7 @@ files:
223
223
  - lib/raindown/code.rb
224
224
  - lib/raindown/code_blocks.rb
225
225
  - lib/raindown/config.rb
226
+ - lib/raindown/context.rb
226
227
  - lib/raindown/directives.rb
227
228
  - lib/raindown/document.rb
228
229
  - lib/raindown/editing.rb
@@ -232,13 +233,13 @@ files:
232
233
  - lib/raindown/endpoint/endpoint_runner.rb
233
234
  - lib/raindown/endpoint/endpoint_variables.rb
234
235
  - lib/raindown/endpoint/schema_block.rb
235
- - lib/raindown/files.rb
236
236
  - lib/raindown/fragments.rb
237
237
  - lib/raindown/front_matter.rb
238
238
  - lib/raindown/gitignore.rb
239
239
  - lib/raindown/heading_ids.rb
240
240
  - lib/raindown/js/host.mjs
241
241
  - lib/raindown/js/js_nodes.rb
242
+ - lib/raindown/list.rb
242
243
  - lib/raindown/markdown_nodes.rb
243
244
  - lib/raindown/node.rb
244
245
  - lib/raindown/node_blocks.rb
@@ -253,7 +254,9 @@ files:
253
254
  - lib/raindown/stat.rb
254
255
  - lib/raindown/table/markdown_table.rb
255
256
  - lib/raindown/table/table.rb
256
- - lib/raindown/table_formatter.rb
257
+ - lib/raindown/table/table_formatter.rb
258
+ - lib/raindown/table/table_formulas.rb
259
+ - lib/raindown/table/written_table.rb
257
260
  - lib/raindown/toc.rb
258
261
  - lib/raindown/tui.rb
259
262
  - lib/raindown/tui/blueprints/blueprints_renderer.rb
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'antlers/api'
4
-
5
- module Raindown
6
- module ListLexeme
7
- include Antlers::Lexeme
8
-
9
- module_function
10
-
11
- KEYWORDS = ['list:', 'folder:', 'order:', ':list'].freeze
12
-
13
- def match?(keywords:, **)
14
- KEYWORDS.include?(keywords.keys.first)
15
- end
16
-
17
- def lexeme(keywords:, **)
18
- if keywords['list:']
19
- *key, value = keywords['list:'].split(',').map(&:strip)
20
-
21
- list_def = { list_def: value, folder: keywords['folder:'] }
22
- list_def[:order] = keywords['order:'] if keywords['order:']
23
- list_def[:key] = key.first unless key.empty?
24
-
25
- return list_def
26
- end
27
-
28
- # TODO: Keep track of which list loop we're in to allow nested list loops.
29
- { list_end: 'level_1' }
30
- end
31
- end
32
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'antlers/api'
4
- require 'nodes/html_node'
5
- require 'nodes/prop_node'
6
- require 'nodes/slot_node'
7
- require_relative '../raindown/fragments'
8
-
9
- module Raindown
10
- # <{ Card name=p.name }>, rendered by Antlers where it is in the template, so its props see loop variables.
11
- # Its HTML is kept as a fragment, so Commonmarker doesn't read it as Markdown.
12
- class PropComponentNode < Antlers::PropNode
13
- def render(**)
14
- Fragments.add(super)
15
- end
16
- end
17
-
18
- # <{ Card: }>...<{ :Card }>, whose slot is its own Markdown, rendered to HTML in its scope first.
19
- #
20
- # Markdown children -> rendered to a Markdown string -> Commonmarker -> HTML
21
- # -> wrapped as a single Antlers::HTMLNode (replaces @children for the super call)
22
- # -> Antlers::SlotNode#render's "without a template" branch -> slot: receives that HTML
23
- # -> Card#render(slot:, **props)
24
- #
25
- # This only reaches Card#render directly when Card has no class-level template (see SlotNode#render);
26
- # otherwise Antlers renders Card's own template instead, with this HTML passed to it as the slot_node.
27
- class SlotComponentNode < Antlers::SlotNode
28
- def render(current_binding: nil, parent_binding: nil, slot_node: nil, metadata: {})
29
- markdown = @children.map { |child| child.render(current_binding:, parent_binding:, slot_node:, metadata:) || '' }.join
30
- children = @children
31
- @children = [Antlers::HTMLNode.new(html: Raindown.commonmark(markdown))]
32
-
33
- Fragments.add(super)
34
- ensure
35
- @children = children if children
36
- end
37
- end
38
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'node'
4
-
5
- module Raindown
6
- # The node behind files:, a list of links to the files the metadata has for its props, like files: folder: 'notes'.
7
- # A project can change how files are listed with its own Files node in .raindown, like "class Files < Raindown::Files".
8
- class Files < Node
9
- def initialize(**tags)
10
- @tags = tags
11
- end
12
-
13
- # Each file has its front matter, its path and its content.
14
- def files(metadata: NoMetadata)
15
- metadata.list(**@tags)
16
- end
17
-
18
- def replace(metadata: NoMetadata)
19
- files(metadata:).map { |file| "- [#{file.title || file.path}](#{file.path})" }.join("\n")
20
- end
21
- end
22
- end