jekyll-local-diagram 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: de548cfc1a4926b2ec2ac5ca55066f8170ffc17f729dc72b226a4d49aa17d9e9
4
+ data.tar.gz: 2133a7317648f1b213463ccb7d67ceb88022c64e35af3a9f9dfb8dd941426e88
5
+ SHA512:
6
+ metadata.gz: 04aeb7e17b67b3a5d3d8cf81dcdd4634c95466428f759ae78f5e726f5abc99e8bb7bcf31648e1525b54f032972e060b0d70bc5bfac313c3f5a2ebd09e33e6808
7
+ data.tar.gz: 1fc3f0d3dc30fae210b900879ed1651eecdecf54b6e7f2fed1d3deed5cbf8783dbeab3fe478f41a868f885a1a035ddbc6b98dc0e5b2e4b86e14856a9f968ad73
data/ext/plantuml.jar ADDED
Binary file
@@ -0,0 +1,15 @@
1
+ module JekyllLocalDiagram
2
+ class MathJaxBlock < JekyllLocalDiagramBlock
3
+ def initialize(tag_name, markup, tokens)
4
+ super
5
+ @ext = 'tex'
6
+ @blockclass = 'mathjax'
7
+ end
8
+
9
+ def build_cmd(input, output)
10
+ "tex2svg \"#{File.read(input)}\"> #{output}"
11
+ end
12
+ end
13
+ end
14
+
15
+ Liquid::Template.register_tag('mathjax', JekyllLocalDiagram::MathJaxBlock)
@@ -0,0 +1,16 @@
1
+ module JekyllLocalDiagram
2
+ class MermaidBlock < JekyllLocalDiagram::JekyllLocalDiagramBlock
3
+ def initialize(tag_name, markup, tokens)
4
+ super
5
+ @ext = 'mmd'
6
+ @blockclass = 'mermaid'
7
+ @puppetercfg = File.join(File.expand_path(File.join(File.dirname(__FILE__), '../..')), '/cfg/puppeteer.json')
8
+ end
9
+
10
+ def build_cmd(input, output)
11
+ "mmdc -i #{input} -o #{output} -p #{@puppetercfg}"
12
+ end
13
+ end
14
+ end
15
+
16
+ Liquid::Template.register_tag('mermaid', JekyllLocalDiagram::MermaidBlock)
@@ -0,0 +1,16 @@
1
+ module JekyllLocalDiagram
2
+ class PlantumlBlock < JekyllLocalDiagram::JekyllLocalDiagramBlock
3
+ def initialize(tag_name, markup, tokens)
4
+ super
5
+ @ext = 'uml'
6
+ @blockclass = 'plantuml'
7
+ @jarpath = File.join(File.expand_path(File.join(File.dirname(__FILE__), '../..')), '/ext/plantuml.jar')
8
+ end
9
+
10
+ def build_cmd(input, output)
11
+ "java -jar #{@jarpath} -tsvg -o #{File.dirname(output)} #{input}"
12
+ end
13
+ end
14
+ end
15
+
16
+ Liquid::Template.register_tag('plantuml', JekyllLocalDiagram::PlantumlBlock)
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'liquid'
4
+ require 'digest'
5
+ require 'fileutils'
6
+ require 'logger'
7
+
8
+ module JekyllLocalDiagram
9
+ class JekyllLocalDiagramBlock < Liquid::Block
10
+ def initialize(tag_name, markup, tokens)
11
+ super
12
+ @html = (markup or '').strip
13
+ @logger = Logger.new(STDOUT)
14
+ @logger.level = Logger::DEBUG
15
+ end
16
+
17
+ def render(context)
18
+ site = context.registers[:site]
19
+ name = Digest::MD5.hexdigest(super)
20
+ path = File.join('assets', 'images', @ext)
21
+ type = 'svg'
22
+ mimetype = 'svg+xml'
23
+ imgfile = "#{name}.#{type}"
24
+ imgpath = File.join(site.source, path)
25
+ if !File.exists?(File.join(imgpath, imgfile))
26
+ txtfile = File.join(imgpath, "#{name}.#{@ext}")
27
+ img = File.join(imgpath, imgfile)
28
+ if File.exists?(img)
29
+ @logger.debug("File #{imgfile} already exists (#{File.size(img)} bytes)")
30
+ else
31
+ FileUtils.mkdir_p(imgpath)
32
+ File.open(txtfile, 'w') { |f|
33
+ f.write(super)
34
+ }
35
+ cmd = build_cmd(txtfile, img)
36
+ @logger.debug("Executing #{@blockclass} command: #{cmd}")
37
+ system(cmd) or raise "#{@blockclass} error: #{super}"
38
+ site.static_files << Jekyll::StaticFile.new(
39
+ site, site.source, path, imgfile
40
+ )
41
+ @logger.debug("File #{imgfile} created (#{File.size(img)} bytes)")
42
+ end
43
+ end
44
+ "<p><object data='#{site.baseurl}/#{path}/#{imgfile}' type='image/#{mimetype}' #{@html} class='#{@blockclass}'></object></p>"
45
+ end
46
+ end
47
+ end
48
+
49
+ require 'block/plantuml-block'
50
+ require 'block/mermaid-block'
51
+ require 'block/mathjax-block'
52
+
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-local-diagram
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Steve Knight
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: liquid
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ description:
42
+ email: steve@hackinghat.com
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - ext/plantuml.jar
48
+ - lib/block/mathjax-block.rb
49
+ - lib/block/mermaid-block.rb
50
+ - lib/block/plantuml-block.rb
51
+ - lib/jekyll-local-diagram.rb
52
+ homepage: https://github.com/hackinghat/jekyll-local-diagram
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.3.7
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Generate local diagrams with support for non-UML diagrams, to be used with
75
+ jekyll-local-diagrams-build-action
76
+ test_files: []