revealing 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 81fadf115300f171aa5b6ea5071c9584118385f1ed0f02da4ed8b8e0203fab9d
4
- data.tar.gz: ad941a12716d1ec2482d3b343117d8f16429a5066a69039236ed317a31d978f9
3
+ metadata.gz: ef4b2fdc591020528e0f08a5edde8a8a6f3de94fdae275fa647d7d2e225be2c0
4
+ data.tar.gz: b41a921acfa28615a1032253357e3c454ea08f02a68642fb2a4d545206b41192
5
5
  SHA512:
6
- metadata.gz: 916258822e1363db167842ea21f301338214453c30a2951a4d7c71131bfc8119067d4d1e92fffc9d3c38c1212fec142888dc913ef4491e1f67b793c02b955e1d
7
- data.tar.gz: e66136a9f4a4e0007236c4e78b22a873a3876561ce72908cb37517ea2aed1240652f94de8767354eb6f6bcf535ed9f826f59a3d75b6aef5ef71f8e4347821c3d
6
+ metadata.gz: 7dbb0c089b935a6fd356c3c035a7c803538a6cedcbe7d013057a408c90d71bbf2842a9e4be8edeebbe04f4da1d053e60250005981fc4ec491febcdb7a3c4757d
7
+ data.tar.gz: 9d0658b8749d5ac2fa13cb8cf68494e4bd20d9feee9b5584d3de3cde8e44849d17adededd59691c1f902a03f4582192673a85272357182c9066dd96ab40b400d
data/README.markdown CHANGED
@@ -37,20 +37,17 @@ Unique features:
37
37
 
38
38
  # TODO
39
39
 
40
- 1. Expose DITAA's `--scale` via attribute
41
- 1. pandoc-ditaa-inline filter could write files to cache dir and read it from there via SHA
42
- - still keep the SVG inline, but do not call ditaa again if unchanged
43
- 1. Make pandoc-ditaa-inline only inline SVG if FORMAT is html (html5?)
44
40
  1. Expose customization of
45
41
  * highlight-style
46
42
  * theme
47
43
  * slideNumber
48
44
  * history
49
45
  1. Provide a docker image so that we can run without installing everything
46
+ 1. Add guard-livereload to the generated project
47
+ 1. Performance: pandoc-ditaa-inline filter could write files to cache dir and read it from there via SHA
48
+ - still keep the SVG inline, but do not call ditaa again if unchanged
50
49
  1. Consider [mermaid-filter](https://github.com/raghur/mermaid-filter)
51
50
  1. Allow self-hosted mathjax (copy to target)
52
51
  1. Charts using [vega-lite](https://vega.github.io/vega-lite/usage/embed.html)
53
- 1. Add guard-livereload to the generated project
54
- 1. PDF output
55
52
  1. Make the initial set of files more meaningful (e.g. add the project name, `git config user.name` etc.)
56
53
  1. Web interface for live editing
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Revealing
4
- VERSION = '1.5.0'
4
+ VERSION = '1.6.0'
5
5
  end
@@ -6,6 +6,7 @@ This is the source of New Presentation. It was generated with [`revealing`](http
6
6
 
7
7
  * Images are resized for the web using [`graphicsmagick`](http://www.graphicsmagick.org/)
8
8
  * `#include` and other [`gpp`](https://logological.org/gpp) features allow organizing the sources of complex presentations
9
+ * Fenced code blocks marked as `ditaa` will be converted to SVG
9
10
  * Files in the `headers` folder are included verbatim in the HTML `<head>` section
10
11
  * MathJax is included and configured to render SVG. To use a specific version, set the environment variable `MATH_JAX_VERSION` to one of of the versions provided by [CDNJS](https://cdnjs.com/libraries/mathjax).
11
12
  * reveal.js is downloaded and unzipped at build time. Set the environment variable `REVEAL_JS_VERSION` to customize which version to use (must be one of the [released versions](https://github.com/hakimel/reveal.js/releases)). If `REVEAL_JS_DIR` is set, the files from this directory are used.
@@ -3,24 +3,49 @@ local function dirname(str)
3
3
  if str:match(".-/.-") then
4
4
  return string.gsub(str, "(.*/)(.*)", "%1")
5
5
  else
6
- return ''
6
+ return '.'
7
7
  end
8
8
  end
9
9
 
10
+ local function convertToSVG(text, scale)
11
+ return pandoc.pipe(
12
+ "java",
13
+ {
14
+ "-Djava.awt.headless=true",
15
+ "-jar", dirname(PANDOC_SCRIPT_FILE) .. '/' .. "lib/ditaa-0.11.0-standalone.jar",
16
+ "-",
17
+ "-",
18
+ "--svg",
19
+ "--scale", scale
20
+ },
21
+ text
22
+ )
23
+ end
24
+
25
+ -- These formats accept embedded SVG
26
+ local SUPPORTED_FORMATS = {
27
+ ['html'] = true, ['html5'] = true, ['html4'] = true, ['slideous'] = true,
28
+ ['slidy'] = true, ['dzslides'] = true, ['revealjs'] = true, ['s5'] = true
29
+ }
30
+
10
31
  function CodeBlock(block)
11
- if block.classes[1] == "ditaa" then
12
- local img = pandoc.pipe(
13
- "java",
14
- {
15
- "-Djava.awt.headless=true",
16
- "-jar", dirname(PANDOC_SCRIPT_FILE) .. '/' .. "lib/ditaa-0.11.0-standalone.jar",
17
- "-",
18
- "-",
19
- "--svg",
20
- "--scale", "1.0"
21
- },
22
- block.text
23
- )
24
- return pandoc.Para({pandoc.RawInline("html", img)})
25
- end
32
+ if not (block.classes[1] == "ditaa") then
33
+ return -- keeps the block's text as literal code block
34
+ end
35
+
36
+ if not SUPPORTED_FORMATS[FORMAT] then
37
+ io.stderr:write(string.format("Warning: Cannot convert DITAA block to SVG for format %s. Keeping literal value.\n", FORMAT))
38
+ return
39
+ end
40
+
41
+ local scale = block.attributes["scale"] or "1.0"
42
+
43
+ success, result = pcall(convertToSVG, block.text, scale)
44
+
45
+ if not success then
46
+ io.stderr:write(string.format("Error - DITAA block could not converted:\n%s\n", result.output))
47
+ else
48
+ -- io.stderr:write("DITAA block converted successfully\n")
49
+ return pandoc.Para({pandoc.RawInline("html", result)})
50
+ end
26
51
  end
@@ -25,7 +25,34 @@
25
25
  <text x='153' y='54' font-family='Courier' font-size='15' stroke='none' fill='#000000' ><![CDATA[B ]]></text>
26
26
  </g>
27
27
  </svg></p>
28
- <p>As you can see, ditaa renders that quite pretty. It’s turned into an embedded SVG.</p>
28
+ <p>The <code>scale</code> attribute can be set so that the generated image is scaled by this factor. This requires the use of <a href="https://pandoc.org/MANUAL.html#extension-fenced_code_attributes">fenced code attributes</a>, where the class is written as <code>.ditaa</code>.</p>
29
+ <p>This is the same image as before, but scaled by factor <code>1.5</code>:</p>
30
+ <p><?xml version='1.0' encoding='UTF-8' standalone='no'?>
31
+ <svg
32
+ xmlns='http://www.w3.org/2000/svg'
33
+ width='315'
34
+ height='147'
35
+ shape-rendering='geometricPrecision'
36
+ version='1.0'>
37
+ <defs>
38
+ <filter id='f2' x='0' y='0' width='200%' height='200%'>
39
+ <feOffset result='offOut' in='SourceGraphic' dx='5' dy='5' />
40
+ <feGaussianBlur result='blurOut' in='offOut' stdDeviation='3' />
41
+ <feBlend in='SourceGraphic' in2='blurOut' mode='normal' />
42
+ </filter>
43
+ </defs>
44
+ <g stroke-width='1' stroke-linecap='square' stroke-linejoin='round'>
45
+ <rect x='0' y='0' width='315' height='147' style='fill: #ffffff'/>
46
+ <path stroke='gray' fill='gray' filter='url(#f2)' d='M37.0 52.0 L37.0 94.0 L127.0 94.0 L127.0 52.0 z' />
47
+ <path stroke='gray' fill='gray' filter='url(#f2)' d='M187.0 94.0 L277.0 94.0 L277.0 52.0 L187.0 52.0 z' />
48
+ <path stroke='#000000' stroke-width='1,500000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M37.0 52.0 L37.0 94.0 L127.0 94.0 L127.0 52.0 z' />
49
+ <path stroke='#000000' stroke-width='1,500000' stroke-linecap='round' stroke-linejoin='round' fill='white' d='M187.0 94.0 L277.0 94.0 L277.0 52.0 L187.0 52.0 z' />
50
+ <path stroke='none' stroke-width='1,500000' stroke-linecap='round' stroke-linejoin='round' fill='#000000' d='M165.0 63.0 L180.0 73.0 L165.0 84.0 z' />
51
+ <path stroke='#000000' stroke-width='1,500000' stroke-linecap='round' stroke-linejoin='round' fill='none' d='M172.0 73.0 L142.0 73.0 ' />
52
+ <text x='79' y='82' font-family='Courier' font-size='22' stroke='none' fill='#000000' ><![CDATA[A ]]></text>
53
+ <text x='230' y='82' font-family='Courier' font-size='22' stroke='none' fill='#000000' ><![CDATA[B ]]></text>
54
+ </g>
55
+ </svg></p>
29
56
  <p>Other blocks are left untouched:</p>
30
57
  <div class="sourceCode" id="cb1"><pre class="sourceCode ruby"><code class="sourceCode ruby"><a class="sourceLine" id="cb1-1" title="1">puts <span class="st">&quot;olleH&quot;</span>.reverse</a></code></pre></div>
31
58
  <p>That’s it!</p>
@@ -6,7 +6,15 @@ The following graph shows two boxes, connected:
6
6
  +-----+ +-----+
7
7
  ```
8
8
 
9
- As you can see, ditaa renders that quite pretty. It's turned into an embedded SVG.
9
+ The `scale` attribute can be set so that the generated image is scaled by this factor. This requires the use of [fenced code attributes](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes), where the class is written as `.ditaa`.
10
+
11
+ This is the same image as before, but scaled by factor `1.5`:
12
+
13
+ ```{.ditaa scale=1.5}
14
+ +-----+ +-----+
15
+ | A |-->| B |
16
+ +-----+ +-----+
17
+ ```
10
18
 
11
19
  Other blocks are left untouched:
12
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: revealing
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
  - Steffen Uhlig