opml2html 0.0.2 → 0.0.3

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: 35579ffe32849ad4716759cbf23028cf33333768292a1634ea1724f4726a98e6
4
- data.tar.gz: 6446148749519f5ef707c30084b67fb69c9aa614962824d1aa40b9ec4355d87f
3
+ metadata.gz: 8e0131ae0abb115a15cafbf60050e6ee4fff9acd3a84d00d35b0d742f4bccdb2
4
+ data.tar.gz: 6d6581e206aa9a10a6b7136bf92256db3a554ec21f5c29123250d383b2337edf
5
5
  SHA512:
6
- metadata.gz: 47f39adaa1897478f24e20aee16beed46b397c5b511b2f43c97533620a0e3788259a5f9de19dbf90889496a1de559ef5fc6d63a33a3a94613eb742fd9c8cb044
7
- data.tar.gz: a582bfd488188023495ee13686686ce0ccae958fe3025be51f6a20a001aaef2f80d92777086a114320f46a103a737b8a5b71bdca61e13d8a50b08dd3efad37ac
6
+ metadata.gz: 6c51c90e04f57ae7e3b7c0193e51a38dd3c4cc697b211c4bc891c238085484c3eeb7b5aa60a77f787c5351edcd29a1dc08b62c4423282393601b78b8da8275c4
7
+ data.tar.gz: a9ab4adccc8fcfafb04b4c562fe65fa11d62defc0a51e96a1f0ca22a54b448cab06d110d960eaeffdf0db7b6a331acb6cbf846eb8994471a2f582099322defbe
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.0.3 - 2025-02-07
6
+
7
+ * Render description for each outlines.
8
+ * Fix outline without XML URI attribute.
9
+
5
10
  ## 0.0.2 - 2025-02-05
6
11
 
7
12
  * Render XML URI hyperlinks.
@@ -11,13 +11,15 @@ module OPML2HTML
11
11
  keys.each do |key|
12
12
  case key
13
13
  in :text
14
- result[:text] = text
14
+ result[:text] = (text or next)
15
15
  in :created
16
- result[:created] = created
16
+ result[:created] = (created or next)
17
17
  in :children
18
- result[:children] = children
18
+ result[:children] = (children or next)
19
19
  in :xml_url
20
- result[:xml_url] = xml_url
20
+ result[:xml_url] = (xml_url or next)
21
+ in :description
22
+ result[:description] = description
21
23
  end
22
24
  end
23
25
  result
@@ -51,6 +53,16 @@ module OPML2HTML
51
53
  end
52
54
  end
53
55
 
56
+ def description
57
+ @description || @empty_description and return @description
58
+ if attributes in [*, Attr[name: "description", value:], *]
59
+ @description = value
60
+ else
61
+ @empty_description = true
62
+ return
63
+ end
64
+ end
65
+
54
66
  def attributes
55
67
  @attributes and return @attributes
56
68
  @node => Element[attributes:]
@@ -42,10 +42,15 @@ module OPML2HTML
42
42
  @document.main.add_child(@document.metadata)
43
43
  end
44
44
 
45
- def body_outline_heading(value)
46
- heading = @document.create_element("h2")
45
+ def body_outline_heading(value, description:, level:)
46
+ heading = @document.create_element("h#{level + 1}")
47
47
  heading.add_child(value)
48
48
  @document.main.add_child(heading)
49
+ if description
50
+ desc = @document.create_element("p")
51
+ desc.content = description
52
+ @document.main.add_child(desc)
53
+ end
49
54
  end
50
55
 
51
56
  def body_outline_text(value)
@@ -54,12 +59,17 @@ module OPML2HTML
54
59
  @document.main.add_child(par)
55
60
  end
56
61
 
57
- def body_outline_rss(fragment, xml_url)
62
+ def body_outline_rss(fragment, xml_url, description: nil)
58
63
  anchor = @document.create_element("a")
59
64
  anchor.add_child(fragment)
60
65
  anchor["href"] = xml_url
61
66
  par = @document.create_element("p")
62
67
  par.add_child(anchor)
68
+ if description
69
+ desc = @document.create_element("p")
70
+ desc.content = description
71
+ par.add_child(desc)
72
+ end
63
73
  @document.main.add_child(par)
64
74
  end
65
75
 
@@ -75,15 +75,15 @@ module OPML2HTML
75
75
 
76
76
  def parse_outline(node, level:)
77
77
  case Outline.new(node)
78
- in text:, xml_url:, children: []
78
+ in text:, xml_url:, description:, children: []
79
79
  value = DocumentFragment.parse(text)
80
- @hook.body_outline_rss(value, xml_url)
80
+ @hook.body_outline_rss(value, xml_url, description:)
81
81
  in text:, children: []
82
82
  value = DocumentFragment.parse(text)
83
83
  @hook.body_outline_text(value)
84
- in text:, children:
84
+ in text:, children:, description:
85
85
  value = DocumentFragment.parse(text)
86
- @hook.body_outline_heading(value)
86
+ @hook.body_outline_heading(value, description:, level:)
87
87
  children.each do |child|
88
88
  (child in Text) and next
89
89
  parse_outline(child, level: level + 1)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OPML2HTML
4
- VERSION = "0.0.2"
4
+ VERSION = "0.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opml2html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - gemmaro
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-05 00:00:00.000000000 Z
11
+ date: 2025-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri