inkmark 0.1.0-aarch64-linux

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.
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Inkmark
4
+ # A rendered table of contents, carrying both Markdown and HTML
5
+ # renderings. Returned by {Inkmark#toc} when the +toc: true+,
6
+ # +statistics: true+, or +extract: { headings: true }+ option is
7
+ # set; +nil+ otherwise.
8
+ #
9
+ # @example
10
+ # g = Inkmark.new(source, options: { toc: true })
11
+ # g.toc.to_markdown # => "- [Intro](#intro)\n - [Goals](#goals)\n"
12
+ # g.toc.to_html # => "<ul>\n<li><a href=\"#intro\">...</a>..."
13
+ # g.toc.to_s # => same as to_markdown (String coercion)
14
+ # puts g.toc # prints the markdown form
15
+ #
16
+ # Immutable value object: the instance is frozen at construction, and
17
+ # +==+ / +eql?+ / +hash+ implement value-equality over the two fields.
18
+ class Toc
19
+ attr_reader :markdown, :html
20
+ alias_method :to_markdown, :markdown
21
+ alias_method :to_html, :html
22
+
23
+ def initialize(markdown:, html:)
24
+ @markdown = markdown
25
+ @html = html
26
+ freeze
27
+ end
28
+
29
+ def to_s = @markdown
30
+
31
+ def ==(other)
32
+ other.is_a?(Toc) && other.markdown == @markdown && other.html == @html
33
+ end
34
+ alias_method :eql?, :==
35
+
36
+ def hash
37
+ [self.class, @markdown, @html].hash
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Inkmark
4
+ # Current gem version.
5
+ VERSION = "0.1.0"
6
+ end