obsidian-parser 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 041aa2c11a3972e24477c8601a880276de98b0108ef7628d9c30b623a1b14cb9
4
- data.tar.gz: 1843bb05271c17a14658c956b7418472f19a5c460d95708f9f3e3fbe7d115d09
3
+ metadata.gz: 10a282bce512c7d763d89eed0aedff250e6721cad6e0849af3821dd897e8d819
4
+ data.tar.gz: d3271c30ab0f7094b6273b0e8f86b33ec2280729fe757958b61459cc0bca5447
5
5
  SHA512:
6
- metadata.gz: 8c21ac0b8b64e487cfbdf7f35c15b486c4094a69dd4d068a90e5d7135159efd148f5df7aaa3ac2a52f327849cb30c5bd698938f0bca9ae4d45e558ab9cb142f2
7
- data.tar.gz: e7f08dda0226319f82135e7bf7374c0f9b6448497f9e7e89a6b1e29a5d0fd0a281a0415d4fc246aae645a91b9cb8a2fb2ac024c941ec2ded63f5089a5ff51dec
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obsidian-parser (0.4.0)
4
+ obsidian-parser (0.5.0)
5
5
  kramdown (~> 2.4)
6
6
  kramdown-parser-gfm (~> 1.1)
7
7
 
@@ -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? ? 1 : 0, c.title] }
87
+ @children.values.sort_by { |c| [c.is_index? ? 0 : 1, c.title] }
81
88
  end
82
89
 
83
90
  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.0"
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.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Moore