obsidian-parser 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 041aa2c11a3972e24477c8601a880276de98b0108ef7628d9c30b623a1b14cb9
4
- data.tar.gz: 1843bb05271c17a14658c956b7418472f19a5c460d95708f9f3e3fbe7d115d09
3
+ metadata.gz: 900eecebc9fbedf86efa15e1913fcdbf661cab7e6cb19453ecbf5b7d956f95b1
4
+ data.tar.gz: 5bbfdbc5cf83fb3149536b54fb427e44a2d5521ca292d7b97af1345e85fa9779
5
5
  SHA512:
6
- metadata.gz: 8c21ac0b8b64e487cfbdf7f35c15b486c4094a69dd4d068a90e5d7135159efd148f5df7aaa3ac2a52f327849cb30c5bd698938f0bca9ae4d45e558ab9cb142f2
7
- data.tar.gz: e7f08dda0226319f82135e7bf7374c0f9b6448497f9e7e89a6b1e29a5d0fd0a281a0415d4fc246aae645a91b9cb8a2fb2ac024c941ec2ded63f5089a5ff51dec
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obsidian-parser (0.4.0)
4
+ obsidian-parser (0.5.1)
5
5
  kramdown (~> 2.4)
6
6
  kramdown-parser-gfm (~> 1.1)
7
7
 
@@ -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
- raise ArgumentError, "Expecting non-empty slug" if path_components.empty?
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? ? 1 : 0, c.title] }
91
+ @children.values.sort_by { |c| [c.is_index? ? 0 : 1, c.title] }
81
92
  end
82
93
 
83
94
  def walk_tree(&block)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Obsidian
4
4
  class Parser
5
- VERSION = "0.4.0"
5
+ VERSION = "0.5.1"
6
6
  end
7
7
  end
@@ -36,19 +36,21 @@ module Obsidian
36
36
 
37
37
  next if basename == "."
38
38
 
39
- # TODO: handle index.md files
40
- if basename != "index.md"
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obsidian-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Moore