obsidian-parser 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/obsidian/parser/page.rb +9 -2
- data/lib/obsidian/parser/version.rb +1 -1
- data/lib/obsidian/parser.rb +12 -10
- 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: 10a282bce512c7d763d89eed0aedff250e6721cad6e0849af3821dd897e8d819
|
4
|
+
data.tar.gz: d3271c30ab0f7094b6273b0e8f86b33ec2280729fe757958b61459cc0bca5447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69cdd0c2c4c6ceb085c9e861d18be91ce3f6b237445f26720bf1787da8448c7ab459c24b4a717d51d1001c7ab9f09b143cb296d28dfee075a869dad9aed10467
|
7
|
+
data.tar.gz: 9511deca5d2844548218b5a7841912b89469b036db63ad3c879c0e246453bf527cb37c732fc3df4e22dfcba4ea5f24e53340dc8572ac0c9372146ee14fb95805
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.5.0] - 2023-07-30
|
4
|
+
- Fix ordering of `Page#children` so that index pages come first.
|
5
|
+
- Fix handling of `index.md` documents so that the slug reflects the directory path.
|
6
|
+
|
3
7
|
## [0.4.0] - 2023-07-30
|
4
8
|
- Unify `Note` and `Index` classes into `Page`. This is a breaking API change. `Parser#notes is replaced by Parse#pages`. Call `Page#is_index?`to distinguish between directory derived pages and documents.
|
5
9
|
- Remove `Parser#table_of_contents` and `Parser#walk_tree`.
|
data/Gemfile.lock
CHANGED
data/lib/obsidian/parser/page.rb
CHANGED
@@ -61,7 +61,9 @@ module Obsidian
|
|
61
61
|
slug: slug,
|
62
62
|
last_modified: last_modified,
|
63
63
|
content: content
|
64
|
-
)
|
64
|
+
).tap do |page|
|
65
|
+
page.update_content(content: content, last_modified: last_modified)
|
66
|
+
end
|
65
67
|
end
|
66
68
|
|
67
69
|
def get_or_create_child(title:, slug:, last_modified: nil, content: nil)
|
@@ -76,8 +78,13 @@ module Obsidian
|
|
76
78
|
)
|
77
79
|
end
|
78
80
|
|
81
|
+
def update_content(content:, last_modified:)
|
82
|
+
@content ||= content
|
83
|
+
@last_modified ||= last_modified
|
84
|
+
end
|
85
|
+
|
79
86
|
def children
|
80
|
-
@children.values.sort_by { |c| [c.is_index? ?
|
87
|
+
@children.values.sort_by { |c| [c.is_index? ? 0 : 1, c.title] }
|
81
88
|
end
|
82
89
|
|
83
90
|
def walk_tree(&block)
|
data/lib/obsidian/parser.rb
CHANGED
@@ -36,19 +36,21 @@ module Obsidian
|
|
36
36
|
|
37
37
|
next if basename == "."
|
38
38
|
|
39
|
-
#
|
40
|
-
|
39
|
+
# Remove the path component "." from the start of the dirname
|
40
|
+
parent_slug = dirname.to_s.gsub(/\A\.\/?/, "")
|
41
|
+
|
42
|
+
if basename.to_s == "index.md"
|
43
|
+
slug = parent_slug.to_s.gsub(/\.md\z/, "")
|
44
|
+
else
|
41
45
|
title = basename.to_s.gsub(/\.md\z/, "")
|
42
|
-
parent_slug = dirname.to_s.gsub(/\A\.\/?/, "")
|
43
46
|
slug = Obsidian.build_slug(title, parent_slug)
|
44
|
-
content = MarkdownContent.new(path)
|
45
|
-
|
46
|
-
@index.add_page(
|
47
|
-
slug,
|
48
|
-
last_modified: path.mtime,
|
49
|
-
content: content
|
50
|
-
)
|
51
47
|
end
|
48
|
+
|
49
|
+
@index.add_page(
|
50
|
+
slug,
|
51
|
+
last_modified: path.mtime,
|
52
|
+
content: MarkdownContent.new(path)
|
53
|
+
)
|
52
54
|
end
|
53
55
|
|
54
56
|
# TODO: capture links between notes
|