jekyll-theme-modootoday 1.5.0 → 1.6.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.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +39 -1
  3. data/README.ko.md +8 -6
  4. data/README.md +8 -6
  5. data/RULES.md +3 -1
  6. data/_includes/modootoday/assets/registry.html +8 -2
  7. data/_includes/modootoday/assets/scripts.html +3 -0
  8. data/_includes/modootoday/assets/sheets.html +3 -0
  9. data/_includes/modootoday/assets/site-scripts.html +8 -3
  10. data/_includes/modootoday/chart/figure.html +4 -0
  11. data/_includes/modootoday/chart/table.html +14 -0
  12. data/_includes/modootoday/chrome/showcase.html +13 -0
  13. data/_includes/modootoday/config.html +8 -5
  14. data/_includes/modootoday/head-meta.html +8 -5
  15. data/_includes/modootoday/i18n/ar.html +1 -1
  16. data/_includes/modootoday/i18n/de.html +1 -1
  17. data/_includes/modootoday/i18n/el.html +1 -1
  18. data/_includes/modootoday/i18n/es.html +1 -1
  19. data/_includes/modootoday/i18n/fa.html +1 -1
  20. data/_includes/modootoday/i18n/fr.html +1 -1
  21. data/_includes/modootoday/i18n/id.html +1 -1
  22. data/_includes/modootoday/i18n/it.html +1 -1
  23. data/_includes/modootoday/i18n/ja.html +1 -1
  24. data/_includes/modootoday/i18n/ko.html +1 -1
  25. data/_includes/modootoday/i18n/ml.html +1 -1
  26. data/_includes/modootoday/i18n/pl.html +1 -1
  27. data/_includes/modootoday/i18n/pt-BR.html +1 -1
  28. data/_includes/modootoday/i18n/ro.html +1 -1
  29. data/_includes/modootoday/i18n/ru.html +1 -1
  30. data/_includes/modootoday/i18n/th.html +1 -1
  31. data/_includes/modootoday/i18n/tr.html +1 -1
  32. data/_includes/modootoday/i18n/uk.html +1 -1
  33. data/_includes/modootoday/i18n/ur-Latn.html +1 -1
  34. data/_includes/modootoday/i18n/vi.html +1 -1
  35. data/_includes/modootoday/i18n/zh-CN.html +1 -1
  36. data/_includes/modootoday/i18n/zh-TW.html +1 -1
  37. data/_includes/modootoday/i18n.html +132 -116
  38. data/_includes/modootoday/links/content.html +6 -2
  39. data/_includes/modootoday/markdown/c/chart.html +24 -0
  40. data/_includes/modootoday/markdown/c/widget.html +22 -0
  41. data/_includes/modootoday/markdown/components.html +4 -2
  42. data/_includes/modootoday/markdown/figures/diagrams.html +31 -0
  43. data/_includes/modootoday/markdown/figures/math.html +34 -0
  44. data/_includes/modootoday/markdown/figures.html +8 -0
  45. data/_includes/modootoday/markdown/inline/chart.html +30 -0
  46. data/_includes/modootoday/markdown/inline/widget.html +19 -0
  47. data/_includes/modootoday/markdown/inline.html +5 -1
  48. data/_includes/modootoday/markdown/sections.html +2 -2
  49. data/_includes/modootoday/render/chart.html +15 -0
  50. data/_includes/modootoday/render/math.html +21 -5
  51. data/_includes/modootoday/render/mermaid.html +4 -3
  52. data/_includes/modootoday/t.html +1 -1
  53. data/_includes/modootoday/version.html +1 -1
  54. data/_layouts/default.html +5 -2
  55. data/_sass/modootoday/blog/_cards.scss +2 -1
  56. data/_sass/modootoday/components/chrome/_showcase.scss +40 -0
  57. data/_sass/modootoday/components/data/_chart.scss +25 -0
  58. data/_sass/modootoday/components/figure/_figure-svg.scss +2 -0
  59. data/_sass/modootoday/components/media/_diagram.scss +14 -0
  60. data/_sass/modootoday/components/media/_widget.scss +7 -0
  61. data/_sass/modootoday/components/section/structure/_timeline.scss +7 -3
  62. data/assets/css/modootoday/chrome/showcase.scss +8 -0
  63. data/assets/css/modootoday/data/chart.scss +7 -0
  64. data/assets/css/modootoday/media/widget.scss +7 -0
  65. data/assets/js/modootoday/chrome/showcase.js +15 -0
  66. data/assets/js/modootoday/chrome/theme-init.js +3 -2
  67. data/assets/js/modootoday/content/scroll-region.js +68 -11
  68. data/assets/js/modootoday/data/chart-table.js +16 -0
  69. data/assets/js/modootoday/data/chart.js +106 -0
  70. data/i18n/ar.yml +14 -1
  71. data/i18n/de.yml +14 -1
  72. data/i18n/el.yml +14 -1
  73. data/i18n/en.yml +14 -1
  74. data/i18n/es.yml +14 -1
  75. data/i18n/fa.yml +14 -1
  76. data/i18n/fr.yml +14 -1
  77. data/i18n/id.yml +14 -1
  78. data/i18n/it.yml +14 -1
  79. data/i18n/ja.yml +14 -1
  80. data/i18n/ko.yml +14 -1
  81. data/i18n/ml.yml +14 -1
  82. data/i18n/pl.yml +14 -1
  83. data/i18n/pt-BR.yml +14 -1
  84. data/i18n/ro.yml +14 -1
  85. data/i18n/ru.yml +14 -1
  86. data/i18n/th.yml +14 -1
  87. data/i18n/tr.yml +14 -1
  88. data/i18n/uk.yml +14 -1
  89. data/i18n/ur-Latn.yml +14 -1
  90. data/i18n/vi.yml +14 -1
  91. data/i18n/zh-CN.yml +14 -1
  92. data/i18n/zh-TW.yml +14 -1
  93. data/lib/modootoday/check/build/build_output.rb +13 -4
  94. data/lib/modootoday/check/build/showcase.rb +27 -0
  95. data/lib/modootoday/check/build/structured_data/nested.rb +29 -0
  96. data/lib/modootoday/check/build/structured_data.rb +6 -3
  97. data/lib/modootoday/check/build/third_party.rb +1 -1
  98. data/lib/modootoday/check/cli.rb +8 -3
  99. data/lib/modootoday/check/config/keys/appearance/showcase.rb +57 -0
  100. data/lib/modootoday/check/config/keys/figures/chart.rb +16 -0
  101. data/lib/modootoday/check/config/keys/figures/diagrams.rb +31 -0
  102. data/lib/modootoday/check/config/keys/serving/delivery.rb +8 -1
  103. data/lib/modootoday/check/config/keys.rb +4 -1
  104. data/lib/modootoday/check/config/renderers.rb +36 -12
  105. data/lib/modootoday/check/config/site_config.rb +1 -1
  106. data/lib/modootoday/check/page/a11y/new_window.rb +3 -2
  107. data/lib/modootoday/check/page/chart.rb +91 -0
  108. data/lib/modootoday/check/page/figures/diagrams.rb +64 -0
  109. data/lib/modootoday/check/page/figures/freshness.rb +55 -0
  110. data/lib/modootoday/check/page/figures/math_static.rb +88 -0
  111. data/lib/modootoday/check/page/math_notation.rb +1 -1
  112. data/lib/modootoday/check/page/pages.rb +22 -0
  113. data/lib/modootoday/check/page/widget.rb +66 -0
  114. data/lib/modootoday/check.rb +1 -0
  115. data/lib/modootoday/figures.rb +88 -0
  116. metadata +34 -2
@@ -0,0 +1,64 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../figures"
4
+
5
+ module Modootoday
6
+ module Check
7
+ # Front matter diagrams: the n-th ```mermaid fence of the page is the n-th entry; each entry names a committed SVG
8
+ # pair under modootoday.diagrams.dir (config/keys/figures/diagrams.rb) and carries the alt text.
9
+ module FigureDiagrams
10
+ KEYS = %w[name alt caption width height].freeze
11
+ NAME = %r{\A(?!.*\.\.)[A-Za-z0-9][A-Za-z0-9._/-]*\z}
12
+
13
+ module_function
14
+
15
+ def call(ctx, f, text)
16
+ fm = Markdown.fm(text) rescue nil
17
+ return unless fm.is_a?(Hash) && fm.key?("diagrams")
18
+ r = ctx.rel(f)
19
+ list = fm["diagrams"]
20
+ return ctx.errs << "#{r}: diagrams: must be a list of {name, alt, caption, width, height}, one per ```mermaid fence" unless list.is_a?(Array)
21
+ body = Markdown.body(text)
22
+ offset = text.lines.size - body.lines.size
23
+ fences = Figures.fences(body, "mermaid")
24
+ count(ctx, r, list, fences.map { |x| x[:line] + offset })
25
+ cfg = Config::Diagrams.settings(ctx.mtc)
26
+ list.each_with_index { |e, i| entry(ctx, r, "diagrams[#{i}]", e, cfg) }
27
+ ctx.warns << "#{r}: diagrams: and mermaid: true together: the page shows the static figures, so the Mermaid loader never runs; remove mermaid: true" if fm["mermaid"] == true
28
+ end
29
+
30
+ def count(ctx, r, list, lines)
31
+ return if lines.size == list.size
32
+ at = lines.empty? ? "none" : "lines #{lines.join(', ')}"
33
+ ctx.errs << "#{r}: diagrams: has #{list.size} #{list.size == 1 ? 'entry' : 'entries'} but the page has #{lines.size} ```mermaid #{lines.size == 1 ? 'fence' : 'fences'} (#{at}); the n-th fence is the n-th entry"
34
+ end
35
+
36
+ def entry(ctx, r, w, e, cfg)
37
+ return ctx.errs << "#{r}: #{w} must be a map with name: and alt:" unless e.is_a?(Hash)
38
+ (e.keys - KEYS).each { |k| ctx.errs << "#{r}: #{w}: unknown key #{k} (#{KEYS.join(', ')})" }
39
+ name = e["name"]
40
+ return ctx.errs << "#{r}: #{w}.name must be a file name without .svg under #{cfg['dir']}, such as flow or guide/flow (got #{name.inspect})" unless name.is_a?(String) && name.match?(NAME) && !name.end_with?(".svg")
41
+ ctx.errs << "#{r}: #{w} (#{name}) needs alt: the text a reader gets instead of the picture; say what the diagram shows" if e["alt"].to_s.strip.empty?
42
+ files(ctx, r, w, name, cfg).then { |light| size(ctx, r, w, e, light) }
43
+ end
44
+
45
+ # The light SVG (and the dark one with dark: true) must exist in the source; returns the light SVG's path or nil.
46
+ def files(ctx, r, w, name, cfg)
47
+ base = File.join(ctx.src, cfg["dir"].to_s, name)
48
+ paths = cfg["dark"] == false ? ["#{base}.svg"] : ["#{base}.svg", "#{base}.dark.svg"]
49
+ paths.reject { |p| File.file?(p) }.each { |p| ctx.errs << "#{r}: #{w}: #{ctx.rel(p)} not found (render the fence and commit the SVG)" }
50
+ File.file?(paths.first) ? paths.first : nil
51
+ end
52
+
53
+ def size(ctx, r, w, e, light)
54
+ given = %w[width height].select { |k| e.key?(k) }
55
+ bad = given.reject { |k| e[k].is_a?(Integer) && e[k].positive? }
56
+ bad.each { |k| ctx.errs << "#{r}: #{w}.#{k} must be a whole number of pixels (got #{e[k].inspect})" }
57
+ return if given.size == 2 || !bad.empty?
58
+ vb = light && Figures.viewbox(File.read(light))
59
+ hint = vb ? "; its viewBox gives width: #{vb[0]}, height: #{vb[1]}" : ""
60
+ ctx.warns << "#{r}: #{w} has no width and height, so the page shifts when the image loads#{hint}"
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../../../figures"
5
+
6
+ module Modootoday
7
+ module Check
8
+ # Whether each listed diagram's committed SVGs were drawn from the fence the page has now: an SVG whose data-mt-src
9
+ # differs from the fence digest is stale. An SVG without data-mt-src is hand-made and not tracked.
10
+ module FigureFreshness
11
+ module_function
12
+
13
+ def call(ctx, f, text)
14
+ renders(ctx, f, text).each do |d|
15
+ next unless d[:reason] == "stale"
16
+ ctx.errs << "#{d[:page]}: #{d[:entry]} (#{d[:name]}): stale diagram: #{d[:stale].join(' and ')} #{d[:stale].size == 1 ? 'was' : 'were'} drawn from another fence than the one at line #{d[:line]} (#{d[:digest]}); render it again (modootoday-check SRC --diagrams lists it)"
17
+ end
18
+ end
19
+
20
+ # --diagrams: every listed diagram whose SVG is missing or stale, as JSON on stdout; 1 when the list is not empty.
21
+ def list(ctx)
22
+ out = ctx.mds.flat_map { |f| renders(ctx, f, File.read(f)).select { |d| d[:reason] } }
23
+ puts JSON.pretty_generate(out.map { |d| d.slice(:page, :name, :line, :fence, :digest, :files, :reason) })
24
+ out.empty? ? 0 : 1
25
+ end
26
+
27
+ # One record per front matter entry that has a fence and a usable name.
28
+ def renders(ctx, f, text)
29
+ fm = Markdown.fm(text) rescue nil
30
+ return [] unless fm.is_a?(Hash) && fm["diagrams"].is_a?(Array)
31
+ body = Markdown.body(text)
32
+ offset = text.lines.size - body.lines.size
33
+ cfg = Config::Diagrams.settings(ctx.mtc)
34
+ fences = Figures.fences(body, "mermaid")
35
+ fm["diagrams"].each_with_index.filter_map do |e, i|
36
+ name = e.is_a?(Hash) && e["name"]
37
+ next unless fences[i] && name.is_a?(String) && name.match?(FigureDiagrams::NAME)
38
+ record(ctx, cfg, ctx.rel(f), "diagrams[#{i}]", name, fences[i], offset)
39
+ end
40
+ end
41
+
42
+ def record(ctx, cfg, page, entry, name, fence, offset)
43
+ base = File.join(cfg["dir"].to_s, name).delete_prefix("/")
44
+ files = { "default" => "#{base}.svg" }
45
+ files["dark"] = "#{base}.dark.svg" unless cfg["dark"] == false
46
+ digest = Figures.digest(fence[:body])
47
+ paths = files.values.map { |p| File.join(ctx.src, p) }
48
+ stale = paths.select { |p| File.file?(p) && (s = Figures.src_of(File.read(p))) && s != digest }
49
+ reason = if paths.any? { |p| !File.file?(p) } then "missing" elsif stale.any? then "stale" end
50
+ { page: page, entry: entry, name: name, line: fence[:line] + offset, fence: fence[:body].chomp, digest: digest,
51
+ files: files, reason: reason, stale: stale.map { |p| ctx.rel(p) } }
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "../../../figures"
5
+
6
+ module Modootoday
7
+ module Check
8
+ # math.mode: static: the n-th ```math fence or $$ block of a page is the n-th entry {src:, html:} of
9
+ # _data/math/<key>.yml (key: Figures.math_key; translations share their source's file). Inline math cannot be static.
10
+ module MathStatic
11
+ KEY = /\A[A-Za-z0-9_-]+\z/
12
+ EXTS = %w[yml yaml json].freeze
13
+ HINT = "render them again (modootoday-check SRC --math lists them)"
14
+
15
+ module_function
16
+
17
+ def call(ctx, f, text)
18
+ return unless Renderers.static_math?(ctx.mtc)
19
+ rec = record(ctx, f, text)
20
+ return unless rec
21
+ r = rec[:page]
22
+ n = inline(text)
23
+ ctx.errs << "#{r}:#{n}: inline math cannot be rendered ahead of time (modootoday.math.mode: static); make it a $$ block on its own lines or a ```math fence" if n
24
+ return ctx.errs << "#{r}: math key #{rec[:key].inspect} is not a data file name Jekyll keeps; set math_key: to letters, digits, - and _" unless rec[:key].match?(KEY) || rec[:blocks].empty?
25
+ data(ctx, r, rec)
26
+ end
27
+
28
+ # The entries against the blocks: the file, the count, each digest, KaTeX HTML without its stylesheet.
29
+ def data(ctx, r, rec)
30
+ blocks, list, file = rec[:blocks], rec[:data], rec[:file]
31
+ return ctx.errs << "#{r}: #{blocks.size} math #{blocks.size == 1 ? 'block' : 'blocks'} but no #{file}; #{HINT}" if list.nil? && blocks.any?
32
+ return if list.nil?
33
+ return ctx.errs << "#{r}: #{file} must be a list of {src:, html:}, one per math block" unless list.is_a?(Array) && list.all? { |e| e.is_a?(Hash) }
34
+ at = blocks.empty? ? "none" : "lines #{blocks.map { |b| b[:line] }.join(', ')}"
35
+ ctx.errs << "#{r}: #{file} has #{list.size} #{list.size == 1 ? 'entry' : 'entries'} but the page has #{blocks.size} math #{blocks.size == 1 ? 'block' : 'blocks'} (#{at}); the n-th block is the n-th entry" if list.size != blocks.size
36
+ blocks.zip(list).each_with_index do |(b, e), i|
37
+ next unless b && e
38
+ ctx.errs << "#{r}:#{b[:line]}: #{file} entry #{i + 1} has no html:" if e["html"].to_s.strip.empty?
39
+ ctx.errs << "#{r}:#{b[:line]}: stale math: entry #{i + 1} of #{file} was rendered from other TeX than this block (#{b[:digest]})#{shared(rec)}; #{HINT}" if e["src"] != b[:digest]
40
+ end
41
+ html = list.any? { |e| e["html"].to_s.include?("katex-html") }
42
+ ctx.errs << "#{r}: #{file} holds KaTeX HTML output, which needs KaTeX's stylesheet: set modootoday.math.css or base, or render MathML" if html && !Renderers.math_urls(ctx.mtc["math"])["css"]
43
+ end
44
+
45
+ # Only a translation or a page with its own math_key: reads a file another page may have rendered.
46
+ def shared(rec) = rec[:shared] ? "; #{rec[:file]} is shared by the pages with key #{rec[:key]}, so render them from one source" : ""
47
+
48
+ # One page: {page:, key:, file:, blocks: [{line:, tex:, digest:}], data:, reason:, shared:}; nil with math: false.
49
+ def record(ctx, f, text)
50
+ fm = Markdown.fm(text) rescue {}
51
+ return nil if fm.is_a?(Hash) && fm["math"] == false
52
+ body = Markdown.body(text)
53
+ offset = text.lines.size - body.lines.size
54
+ blocks = Figures.math_blocks(body).map { |b| { line: b[:line] + offset, tex: b[:body].chomp, digest: Figures.digest(b[:body]) } }
55
+ rel = ctx.rel(f)
56
+ key = Figures.math_key(rel, ctx.page_lang, fm)
57
+ path = EXTS.map { |x| File.join(ctx.src, "_data/math/#{key}.#{x}") }.find { |p| File.file?(p) }
58
+ list = path && load(path)
59
+ reason = if list.nil? then ("missing" if blocks.any?) elsif !list.is_a?(Array) || list.size != blocks.size || blocks.zip(list).any? { |b, e| !e.is_a?(Hash) || e["src"] != b[:digest] } then "stale" end
60
+ shared = ctx.page_lang.translation?(rel) || (fm.is_a?(Hash) && !fm["math_key"].to_s.empty?)
61
+ { page: rel, key: key, file: path ? ctx.rel(path) : "_data/math/#{key}.yml", blocks: blocks, data: list, reason: reason, shared: shared }
62
+ end
63
+
64
+ def load(path) = path.end_with?(".json") ? JSON.parse(File.read(path)) : YAML.safe_load(File.read(path))
65
+
66
+ # Line of the first inline $…$ or $$…$$ (inside a sentence) outside code and math blocks, or nil.
67
+ def inline(text)
68
+ body = Markdown.body(text)
69
+ offset = text.lines.size - body.lines.size
70
+ inside = Figures.math_blocks(body).flat_map { |b| (b[:line]..b[:last]).to_a }
71
+ Markdown.strip_code(body).each_line.with_index(1) do |l, n|
72
+ next if inside.include?(n) || l =~ /\A {4}|\A\t/
73
+ return n + offset if l.include?("$$") || l.gsub("$$", "") =~ Renderers::DOLLAR
74
+ end
75
+ nil
76
+ end
77
+
78
+ # --math: per data file whose page has missing or stale entries, the blocks to render, as JSON; 1 when any.
79
+ def list(ctx)
80
+ recs = Renderers.static_math?(ctx.mtc) ? ctx.mds.filter_map { |f| record(ctx, f, File.read(f)) } : []
81
+ recs = recs.select { |x| x[:key].match?(KEY) }.group_by { |x| x[:key] }.values
82
+ out = recs.map { |g| g.find { |x| !ctx.page_lang.translation?(x[:page]) } || g.first }.select { |x| x[:reason] }
83
+ puts JSON.pretty_generate(out.map { |x| x.slice(:key, :file, :page, :blocks, :reason) })
84
+ out.empty? ? 0 : 1
85
+ end
86
+ end
87
+ end
88
+ end
@@ -11,7 +11,7 @@ module Modootoday
11
11
  # ```math fences and $$ blocks are the standard notation; inline $…$ renders only with inline: true.
12
12
  def notation(ctx)
13
13
  x = ctx.mtc.is_a?(Hash) ? ctx.mtc["math"] : nil
14
- return unless x.is_a?(Hash) && x["enabled"] == true && x["inline"] != true && ctx.respond_to?(:mds)
14
+ return unless x.is_a?(Hash) && x["enabled"] == true && x["inline"] != true && ctx.respond_to?(:mds) && !static_math?(ctx.mtc)
15
15
  ctx.mds.each do |f|
16
16
  n = inline_dollar(File.read(f))
17
17
  ctx.warns << "#{ctx.rel(f)}:#{n}: inline $…$ stays plain text on this site (modootoday.math.inline is false); use a ```math fence or a $$ block, or set inline: true" if n
@@ -6,9 +6,14 @@ require_relative "component_rules"
6
6
  require_relative "page_sections"
7
7
  require_relative "hero_script"
8
8
  require_relative "filter"
9
+ require_relative "chart"
10
+ require_relative "widget"
9
11
  require_relative "a11y/content"
10
12
  require_relative "a11y/new_window"
11
13
  require_relative "a11y/illustration"
14
+ require_relative "figures/diagrams"
15
+ require_relative "figures/freshness"
16
+ require_relative "figures/math_static"
12
17
 
13
18
  module Modootoday
14
19
  module Check
@@ -20,6 +25,7 @@ module Modootoday
20
25
  unchecked(ctx)
21
26
  ctx.mds.each do |f|
22
27
  text = File.read(f)
28
+ next licence(ctx, f) if licence?(f, text)
23
29
  b = Markdown.body(text)
24
30
  code = Markdown.strip_code(b)
25
31
  h2 = PageSyntax.call(ctx, f, text, b, code)
@@ -27,11 +33,27 @@ module Modootoday
27
33
  ComponentRules.inline(ctx, ctx.rel(f), b)
28
34
  PageSections.call(ctx, f, text, b, code, h2)
29
35
  Filter.call(ctx, f, text, b, code)
36
+ Chart.call(ctx, f, text, b, code)
37
+ Widget.call(ctx, f, text, b, code)
30
38
  A11yContent.call(ctx, f, Markdown.strip_comments(code))
31
39
  NewWindow.call(ctx, f, text, Markdown.strip_comments(code))
40
+ FigureDiagrams.call(ctx, f, text)
41
+ FigureFreshness.call(ctx, f, text)
42
+ MathStatic.call(ctx, f, text)
32
43
  end
33
44
  end
34
45
 
46
+ LICENCE = /\A(?:.+\.)?(?:LICEN[CS]E|COPYING|NOTICE)\z/i
47
+
48
+ # A vendored licence (chart.LICENSE.md) without front matter is no page of the site's, but the Pages builder
49
+ # renders Markdown without front matter, so the page rules would only misreport it.
50
+ def licence?(f, text) = File.basename(f, ".md").match?(LICENCE) && !(text.start_with?("---\n") && text =~ Markdown::FM)
51
+
52
+ def licence(ctx, f)
53
+ txt = ctx.rel(f).delete_suffix(".md") + ".txt"
54
+ ctx.errs << "#{ctx.rel(f)}: a licence file saved as Markdown becomes a page on GitHub Pages; save it as #{txt}, or list it in exclude:"
55
+ end
56
+
35
57
  # Jekyll also renders .markdown, .mkd and .mkdn (jekyll new writes about.markdown); the rules read only .md.
36
58
  def unchecked(ctx)
37
59
  Dir.glob("#{ctx.src}/**/*.{markdown,mkd,mkdn}").reject { |f| ctx.skipped?(f) }.sort.each do |f|
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Modootoday
4
+ module Check
5
+ # Widgets: c: widget sections and `widget:<element>` paragraphs place a custom element that a modootoday.scripts entry
6
+ # defines (element:). Props reach the element as JSON in data-props, so they are plain values; the section text is the
7
+ # element's fallback, so a section needs a lead paragraph.
8
+ module Widget
9
+ SPAN = /\A`widget:([^`]*)`\z/
10
+
11
+ module_function
12
+
13
+ def call(ctx, f, text, b, code)
14
+ r = ctx.rel(f)
15
+ meta = begin Markdown.fm(text) rescue {} end
16
+ meta = {} unless meta.is_a?(Hash)
17
+ els = elements(ctx)
18
+ inline(ctx, r, Markdown.strip_fences(b).lines, els)
19
+ props(ctx, "#{r}: widget_props", meta["widget_props"], els) if meta.key?("widget_props")
20
+ secs = meta["sections"].is_a?(Array) ? meta["sections"] : []
21
+ return unless secs.any? { |s| s.is_a?(Hash) && s["c"] == "widget" }
22
+ mds = PageSections.section_markdown(b, code)
23
+ secs.each_with_index { |s, i| section(ctx, "#{r}: sections[#{i}] widget", s, mds[i], els) if s.is_a?(Hash) && s["c"] == "widget" }
24
+ end
25
+
26
+ def elements(ctx)
27
+ scripts = ctx.mtc.is_a?(Hash) && ctx.mtc["scripts"].is_a?(Hash) ? ctx.mtc["scripts"] : {}
28
+ scripts.values.filter_map { |e| e["element"] if e.is_a?(Hash) && e["element"].is_a?(String) }
29
+ end
30
+
31
+ def inline(ctx, r, lines, els)
32
+ lines.each do |l|
33
+ v = l.strip[SPAN, 1]
34
+ next unless v
35
+ ctx.errs << "#{r}: `widget:#{v}`: no modootoday.scripts entry has element: #{v}, so it stays a code span" unless els.include?(v)
36
+ end
37
+ end
38
+
39
+ def props(ctx, w, v, els)
40
+ return ctx.errs << "#{w} must be a map of element names to props maps" unless v.is_a?(Hash)
41
+ v.each do |el, p|
42
+ ctx.warns << "#{w}.#{el}: no modootoday.scripts entry has element: #{el}" unless els.include?(el)
43
+ plain(ctx, "#{w}.#{el}", p)
44
+ end
45
+ end
46
+
47
+ def plain(ctx, w, p)
48
+ return ctx.errs << "#{w} must be a map of names to plain values" unless p.is_a?(Hash)
49
+ bad = p.reject { |_, x| x.nil? || x.is_a?(String) || x.is_a?(Numeric) || x == true || x == false }.keys
50
+ ctx.errs << "#{w}: #{bad.join(', ')} must be a plain value (text, a number, true or false)" unless bad.empty?
51
+ end
52
+
53
+ # With a _data/components.yml widget row, the registry checks the required param and the lead slot.
54
+ def section(ctx, w, s, md, els)
55
+ el = s["widget"]
56
+ own = !(ctx.comps.is_a?(Hash) && ctx.comps.key?("widget"))
57
+ ctx.errs << "#{w}: needs widget: <element> (the element: of a modootoday.scripts entry)" if own && !(el.is_a?(String) && !el.empty?)
58
+ ctx.errs << "#{w}: widget: #{el} is not the element: of any modootoday.scripts entry" if el.is_a?(String) && !el.empty? && !els.include?(el)
59
+ plain(ctx, "#{w}.props", s["props"]) if s.key?("props")
60
+ return unless own
61
+ problem = Slots.count_problem("lead", { "min" => 1 }, md)
62
+ ctx.errs << "#{w}: needs a paragraph after the heading, the text shown until the widget runs" if problem
63
+ end
64
+ end
65
+ end
66
+ end
@@ -34,4 +34,5 @@ require_relative "check/source/gh_render"
34
34
  require_relative "check/config/renderers"
35
35
  require_relative "check/page/math_notation"
36
36
  require_relative "check/build/third_party"
37
+ require_relative "check/build/showcase"
37
38
  require_relative "check/cli"
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "digest"
4
+
5
+ module Modootoday
6
+ # Static figures: the fences and math blocks a page replaces with committed renders, and the one digest rule that
7
+ # ties a render to its source (data-mt-src on an SVG root, src: in _data/math). Other tools must follow digest exactly.
8
+ module Figures
9
+ FENCE_OPEN = /\A {0,3}(`{3,}|~{3,})\s*(\S*)/
10
+ SRC_ATTR = /\A\s*(?:<\?xml[^>]*>\s*)?(?:<!--.*?-->\s*)*<svg\b[^>]*?\sdata-mt-src="([^"]*)"/m
11
+ VIEWBOX = /\A\s*(?:<\?xml[^>]*>\s*)?(?:<!--.*?-->\s*)*<svg\b[^>]*?\sviewBox="\s*[-\d.]+[\s,]+[-\d.]+[\s,]+([\d.]+)[\s,]+([\d.]+)\s*"/m
12
+
13
+ module_function
14
+
15
+ # "sha256-<hex>" of the fence body with CRLF and CR as LF and trailing newlines removed.
16
+ def digest(body) = "sha256-#{Digest::SHA256.hexdigest(body.gsub(/\r\n?/, "\n").sub(/\n+\z/, ''))}"
17
+
18
+ # Fences of one language in a Markdown body, in order: [{line:, body:}] (line of the opening fence, 1-based).
19
+ def fences(text, lang)
20
+ out = []
21
+ cur = nil
22
+ text.each_line.with_index(1) do |l, n|
23
+ if cur
24
+ if closes?(cur, l)
25
+ out << { line: cur[:line], body: cur[:lines].join } if cur[:lang] == lang
26
+ cur = nil
27
+ else
28
+ cur[:lines] << l
29
+ end
30
+ elsif (cur = opens(l, n))
31
+ cur
32
+ end
33
+ end
34
+ out
35
+ end
36
+
37
+ # ```math fences and $$ blocks in document order: [{line:, last:, body:}]. A $$ block's body is the text between
38
+ # its delimiters, on one line or several, without blockquote markers and indentation, trimmed.
39
+ def math_blocks(text)
40
+ out = []
41
+ cur = nil
42
+ text.each_line.with_index(1) do |l, n|
43
+ s = l.sub(/\A(?:[ \t]*>)*[ \t]*/, "").chomp
44
+ if cur&.key?(:mark)
45
+ next cur[:lines] << l unless closes?(cur, l)
46
+ out << { line: cur[:line], last: n, body: cur[:lines].join } if cur[:lang] == "math"
47
+ cur = nil
48
+ elsif cur
49
+ next cur[:lines] << s unless s.end_with?("$$")
50
+ out << { line: cur[:line], last: n, body: (cur[:lines] << s[0...-2]).join("\n").strip }
51
+ cur = nil
52
+ elsif (cur = opens(l, n))
53
+ cur
54
+ elsif s.start_with?("$$")
55
+ rest = s[2..]
56
+ next cur = { line: n, lines: [rest] } unless rest.size >= 2 && rest.end_with?("$$")
57
+ out << { line: n, last: n, body: rest[0...-2].strip }
58
+ end
59
+ end
60
+ out
61
+ end
62
+
63
+ # The _data/math file name of a page: math_key: from front matter, else the default-language source path
64
+ # without its extension, with / as --. page_lang is a Modootoday::I18n::PageLang.
65
+ def math_key(rel, page_lang, fm = {})
66
+ given = fm.is_a?(Hash) ? fm["math_key"] : nil
67
+ return given.to_s unless given.nil? || given.to_s.empty?
68
+ page_lang.source(rel).sub(/\.[^.\/]+\z/, "").gsub("/", "--")
69
+ end
70
+
71
+ def opens(l, n)
72
+ m = l.match(FENCE_OPEN)
73
+ return nil unless m && !(m[1].start_with?("`") && l.count("`") > m[1].size)
74
+ { mark: m[1], lang: m[2].downcase, line: n, lines: [] }
75
+ end
76
+
77
+ def closes?(cur, l) = l.match?(/\A {0,3}#{Regexp.escape(cur[:mark][0])}{#{cur[:mark].size},}\s*\z/)
78
+
79
+ # The data-mt-src of an SVG's root element, or nil.
80
+ def src_of(svg) = svg[SRC_ATTR, 1]
81
+
82
+ # [width, height] of an SVG's viewBox, rounded up to whole pixels, or nil.
83
+ def viewbox(svg)
84
+ m = svg.match(VIEWBOX)
85
+ m && [m[1].to_f.ceil, m[2].to_f.ceil]
86
+ end
87
+ end
88
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-modootoday
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - modootoday
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-05 00:00:00.000000000 Z
11
+ date: 2026-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -70,8 +70,11 @@ files:
70
70
  - _includes/modootoday/brand/icon.html
71
71
  - _includes/modootoday/brand/logo.html
72
72
  - _includes/modootoday/breadcrumb.html
73
+ - _includes/modootoday/chart/figure.html
74
+ - _includes/modootoday/chart/table.html
73
75
  - _includes/modootoday/chrome/footer.html
74
76
  - _includes/modootoday/chrome/nav-sheet.html
77
+ - _includes/modootoday/chrome/showcase.html
75
78
  - _includes/modootoday/config.html
76
79
  - _includes/modootoday/detail/cover.html
77
80
  - _includes/modootoday/detail/cta.html
@@ -143,6 +146,7 @@ files:
143
146
  - _includes/modootoday/lookup/crumbs.html
144
147
  - _includes/modootoday/lookup/page.html
145
148
  - _includes/modootoday/lookup/urls.html
149
+ - _includes/modootoday/markdown/c/chart.html
146
150
  - _includes/modootoday/markdown/c/details.html
147
151
  - _includes/modootoday/markdown/c/faq.html
148
152
  - _includes/modootoday/markdown/c/filetree.html
@@ -152,9 +156,15 @@ files:
152
156
  - _includes/modootoday/markdown/c/pricing.html
153
157
  - _includes/modootoday/markdown/c/quote.html
154
158
  - _includes/modootoday/markdown/c/subscribe.html
159
+ - _includes/modootoday/markdown/c/widget.html
155
160
  - _includes/modootoday/markdown/code.html
156
161
  - _includes/modootoday/markdown/components.html
162
+ - _includes/modootoday/markdown/figures.html
163
+ - _includes/modootoday/markdown/figures/diagrams.html
164
+ - _includes/modootoday/markdown/figures/math.html
157
165
  - _includes/modootoday/markdown/inline.html
166
+ - _includes/modootoday/markdown/inline/chart.html
167
+ - _includes/modootoday/markdown/inline/widget.html
158
168
  - _includes/modootoday/markdown/lists.html
159
169
  - _includes/modootoday/markdown/llms-pages.html
160
170
  - _includes/modootoday/markdown/packages.html
@@ -187,6 +197,7 @@ files:
187
197
  - _includes/modootoday/records/lookup.html
188
198
  - _includes/modootoday/ref-url.html
189
199
  - _includes/modootoday/render/asset.html
200
+ - _includes/modootoday/render/chart.html
190
201
  - _includes/modootoday/render/math.html
191
202
  - _includes/modootoday/render/mermaid.html
192
203
  - _includes/modootoday/search.json
@@ -266,6 +277,7 @@ files:
266
277
  - _sass/modootoday/blog/_news.scss
267
278
  - _sass/modootoday/blog/_post.scss
268
279
  - _sass/modootoday/components/bleed/_bleed.scss
280
+ - _sass/modootoday/components/chrome/_showcase.scss
269
281
  - _sass/modootoday/components/core/chrome/_banner.scss
270
282
  - _sass/modootoday/components/core/chrome/_breadcrumb.scss
271
283
  - _sass/modootoday/components/core/chrome/_header.scss
@@ -284,6 +296,7 @@ files:
284
296
  - _sass/modootoday/components/core/inline/_kbd.scss
285
297
  - _sass/modootoday/components/core/inline/_progress.scss
286
298
  - _sass/modootoday/components/core/inline/_reveal.scss
299
+ - _sass/modootoday/components/data/_chart.scss
287
300
  - _sass/modootoday/components/doc/_page-actions.scss
288
301
  - _sass/modootoday/components/doc/_sidebar.scss
289
302
  - _sass/modootoday/components/doc/_toc.scss
@@ -292,6 +305,8 @@ files:
292
305
  - _sass/modootoday/components/footer/_footer.scss
293
306
  - _sass/modootoday/components/lists/_lists.scss
294
307
  - _sass/modootoday/components/loading/_loading.scss
308
+ - _sass/modootoday/components/media/_diagram.scss
309
+ - _sass/modootoday/components/media/_widget.scss
295
310
  - _sass/modootoday/components/search/_search.scss
296
311
  - _sass/modootoday/components/section/showcase/_card.scss
297
312
  - _sass/modootoday/components/section/showcase/_cta.scss
@@ -365,12 +380,14 @@ files:
365
380
  - assets/css/modootoday/chrome/doc-nav.scss
366
381
  - assets/css/modootoday/chrome/footer.scss
367
382
  - assets/css/modootoday/chrome/search.scss
383
+ - assets/css/modootoday/chrome/showcase.scss
368
384
  - assets/css/modootoday/chrome/terminal.scss
369
385
  - assets/css/modootoday/content/code.scss
370
386
  - assets/css/modootoday/content/extras.scss
371
387
  - assets/css/modootoday/content/inline.scss
372
388
  - assets/css/modootoday/content/lists.scss
373
389
  - assets/css/modootoday/content/loading.scss
390
+ - assets/css/modootoday/data/chart.scss
374
391
  - assets/css/modootoday/data/filter.scss
375
392
  - assets/css/modootoday/data/table-stack.scss
376
393
  - assets/css/modootoday/data/table.scss
@@ -378,6 +395,7 @@ files:
378
395
  - assets/css/modootoday/marketing/hero.scss
379
396
  - assets/css/modootoday/media/figure.scss
380
397
  - assets/css/modootoday/media/visual.scss
398
+ - assets/css/modootoday/media/widget.scss
381
399
  - assets/css/modootoday/showcase/card.scss
382
400
  - assets/css/modootoday/showcase/cta.scss
383
401
  - assets/css/modootoday/showcase/gallery.scss
@@ -401,10 +419,13 @@ files:
401
419
  - assets/js/modootoday/chrome/menu.js
402
420
  - assets/js/modootoday/chrome/search-keys.js
403
421
  - assets/js/modootoday/chrome/search.js
422
+ - assets/js/modootoday/chrome/showcase.js
404
423
  - assets/js/modootoday/chrome/theme-init.js
405
424
  - assets/js/modootoday/chrome/theme-toggle.js
406
425
  - assets/js/modootoday/content/code-copy.js
407
426
  - assets/js/modootoday/content/scroll-region.js
427
+ - assets/js/modootoday/data/chart-table.js
428
+ - assets/js/modootoday/data/chart.js
408
429
  - assets/js/modootoday/data/filter-chips.js
409
430
  - assets/js/modootoday/data/filter.js
410
431
  - assets/js/modootoday/data/table-stack.js
@@ -453,8 +474,10 @@ files:
453
474
  - lib/modootoday/check/build/built_parts.rb
454
475
  - lib/modootoday/check/build/byte_exact.rb
455
476
  - lib/modootoday/check/build/records.rb
477
+ - lib/modootoday/check/build/showcase.rb
456
478
  - lib/modootoday/check/build/site_assets.rb
457
479
  - lib/modootoday/check/build/structured_data.rb
480
+ - lib/modootoday/check/build/structured_data/nested.rb
458
481
  - lib/modootoday/check/build/term_sets.rb
459
482
  - lib/modootoday/check/build/third_party.rb
460
483
  - lib/modootoday/check/build/twins.rb
@@ -463,8 +486,11 @@ files:
463
486
  - lib/modootoday/check/config/keys/appearance/chrome.rb
464
487
  - lib/modootoday/check/config/keys/appearance/color_scheme.rb
465
488
  - lib/modootoday/check/config/keys/appearance/components.rb
489
+ - lib/modootoday/check/config/keys/appearance/showcase.rb
466
490
  - lib/modootoday/check/config/keys/appearance/switches.rb
467
491
  - lib/modootoday/check/config/keys/appearance/tokens.rb
492
+ - lib/modootoday/check/config/keys/figures/chart.rb
493
+ - lib/modootoday/check/config/keys/figures/diagrams.rb
468
494
  - lib/modootoday/check/config/keys/pages/content.rb
469
495
  - lib/modootoday/check/config/keys/pages/edit_url.rb
470
496
  - lib/modootoday/check/config/keys/pages/languages.rb
@@ -493,7 +519,11 @@ files:
493
519
  - lib/modootoday/check/page/a11y/content.rb
494
520
  - lib/modootoday/check/page/a11y/illustration.rb
495
521
  - lib/modootoday/check/page/a11y/new_window.rb
522
+ - lib/modootoday/check/page/chart.rb
496
523
  - lib/modootoday/check/page/component_rules.rb
524
+ - lib/modootoday/check/page/figures/diagrams.rb
525
+ - lib/modootoday/check/page/figures/freshness.rb
526
+ - lib/modootoday/check/page/figures/math_static.rb
497
527
  - lib/modootoday/check/page/filter.rb
498
528
  - lib/modootoday/check/page/hero_script.rb
499
529
  - lib/modootoday/check/page/math_notation.rb
@@ -502,6 +532,7 @@ files:
502
532
  - lib/modootoday/check/page/page_values.rb
503
533
  - lib/modootoday/check/page/pages.rb
504
534
  - lib/modootoday/check/page/slots.rb
535
+ - lib/modootoday/check/page/widget.rb
505
536
  - lib/modootoday/check/registry/i18n.rb
506
537
  - lib/modootoday/check/registry/i18n_pages.rb
507
538
  - lib/modootoday/check/registry/registry.rb
@@ -509,6 +540,7 @@ files:
509
540
  - lib/modootoday/check/source/github_pages.rb
510
541
  - lib/modootoday/check/source/site_hook.rb
511
542
  - lib/modootoday/check/source/stylesheets.rb
543
+ - lib/modootoday/figures.rb
512
544
  - lib/modootoday/i18n.rb
513
545
  - lib/modootoday/i18n/page_lang.rb
514
546
  - lib/modootoday/i18n/source_rev.rb