obsidian-parser 0.4.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/CHANGELOG.md +7 -0
- data/Gemfile.lock +1 -1
- data/lib/obsidian/parser/page.rb +14 -3
- 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: 900eecebc9fbedf86efa15e1913fcdbf661cab7e6cb19453ecbf5b7d956f95b1
|
4
|
+
data.tar.gz: 5bbfdbc5cf83fb3149536b54fb427e44a2d5521ca292d7b97af1345e85fa9779
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bac7a436c5a2bb2a8568c4ba306d769584813ac5da89f9d3051c601f347c22abe6b6009dc4ca988912dd13af32d2c25e7dc15943a3032a871b3ba656200271d
|
7
|
+
data.tar.gz: deba24083f278d7c0b060f798f86de8d95a2a451e899577fbcda4f98046c5d0083554c55d8cfd35eedde085c21fde64cc01d6923d3a8f60aa388f4a412f64183
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.5.1] - 2023-07-30
|
4
|
+
- Fix handling of `index.md` at the root level.
|
5
|
+
|
6
|
+
## [0.5.0] - 2023-07-30
|
7
|
+
- Fix ordering of `Page#children` so that index pages come first.
|
8
|
+
- Fix handling of `index.md` documents so that the slug reflects the directory path.
|
9
|
+
|
3
10
|
## [0.4.0] - 2023-07-30
|
4
11
|
- 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
12
|
- Remove `Parser#table_of_contents` and `Parser#walk_tree`.
|
data/Gemfile.lock
CHANGED
data/lib/obsidian/parser/page.rb
CHANGED
@@ -47,7 +47,11 @@ module Obsidian
|
|
47
47
|
# are added before their descendents.
|
48
48
|
def add_page(slug, last_modified: nil, content: nil)
|
49
49
|
path_components = slug.split("/")
|
50
|
-
|
50
|
+
|
51
|
+
if path_components.empty?
|
52
|
+
update_content(content: content, last_modified: last_modified)
|
53
|
+
return
|
54
|
+
end
|
51
55
|
|
52
56
|
title = path_components.pop
|
53
57
|
|
@@ -61,7 +65,9 @@ module Obsidian
|
|
61
65
|
slug: slug,
|
62
66
|
last_modified: last_modified,
|
63
67
|
content: content
|
64
|
-
)
|
68
|
+
).tap do |page|
|
69
|
+
page.update_content(content: content, last_modified: last_modified)
|
70
|
+
end
|
65
71
|
end
|
66
72
|
|
67
73
|
def get_or_create_child(title:, slug:, last_modified: nil, content: nil)
|
@@ -76,8 +82,13 @@ module Obsidian
|
|
76
82
|
)
|
77
83
|
end
|
78
84
|
|
85
|
+
def update_content(content:, last_modified:)
|
86
|
+
@content ||= content
|
87
|
+
@last_modified ||= last_modified
|
88
|
+
end
|
89
|
+
|
79
90
|
def children
|
80
|
-
@children.values.sort_by { |c| [c.is_index? ?
|
91
|
+
@children.values.sort_by { |c| [c.is_index? ? 0 : 1, c.title] }
|
81
92
|
end
|
82
93
|
|
83
94
|
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
|