Skip to content

Commit 9c6826a

Browse files
committed
Merge remote-tracking branch 'origin/master' into path
2 parents 5409bae + 1b6c38c commit 9c6826a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+352
-177
lines changed

.github/workflows/gh-pages.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
- name: copy
4242
run: cp -R ./_site_jekyll/* ./_site/
4343
- name: Upload artifact
44-
uses: actions/upload-pages-artifact@v2
44+
uses: actions/upload-pages-artifact@v3.0.1
4545

4646
# Deployment job
4747
deploy:
@@ -53,4 +53,4 @@ jobs:
5353
steps:
5454
- name: Deploy to GitHub Pages
5555
id: deployment
56-
uses: actions/deploy-pages@v2
56+
uses: actions/deploy-pages@v4

.github/workflows/pr_visual_flow.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
build:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616
- name: Install Libreoffice for tests
1717
run: sudo apt-get update && sudo apt-get install -y libreoffice-core libreoffice-writer libreoffice-java-common imagemagick ghostscript --no-install-recommends
1818
- name: Set PDF Policy
@@ -24,16 +24,19 @@ jobs:
2424
- name: Test Clojure
2525
run: make visual-test
2626
- name: Archive diff png
27-
uses: actions/upload-artifact@v3
27+
uses: actions/upload-artifact@v4
2828
if: failure()
2929
with:
3030
name: test-visual-images
3131
path: |
3232
/home/runner/work/_temp/**/*.png
33+
/home/runner/work/_temp/**/*.docx
34+
/home/runner/work/_temp/**/*.pdf
35+
target/surefire-reports/*.xml
3336
- name: Test Report
34-
uses: dorny/test-reporter@v1
37+
uses: dorny/test-reporter@v2
3538
if: success() || failure()
3639
with:
3740
name: Visual Tests
3841
path: target/surefire-reports/*.xml
39-
reporter: java-junit
42+
reporter: java-junit

CHANGELOG.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Change Log
2+
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).
3+
4+
## [Unreleased]
5+
### Changed
6+
- ....
7+
8+
## [0.6.1] - 2024-08-03
9+
### Changed
10+
- Update GraalVM version for service
11+
- Fix reflection errors in Docker service
12+
- Introduce functions provider SPI #166
13+
- Add Makefile
14+
15+
## [0.6.0] - 2024-07-26
16+
### Changed
17+
- Refactor stencil.merger` namespace in trampoline style #152
18+
19+
## [0.5.9] - 2024-07-14
20+
### Changed
21+
- Make `replaceImage()` work with `imagedata` tags.
22+
- Introduce `deps.edn` for building and kaocha for tests #164
23+
- Fix: all test namespaces have `-test` suffix
24+
25+
## [0.5.8] - 2024-05-21
26+
### Changed
27+
- Simplified Java API
28+
- Fixed some type hints
29+
- Some internal code reorganization
30+
- Extract fragment handling into a separate namespace #157
31+
- Introduce `stencil.fs` namespace with test cases
32+
- Several fixes in CI: unit test reporting, javadoc generation, etc.
33+
- Fix PPTX file rendering #161
34+
35+
## [0.5.7] - 2023-11-15
36+
### Changed
37+
- Allow expression in fragment include directives #154
38+
39+
## [0.5.6] - 2023-11-03
40+
### Changed
41+
- Fix: backport to work with Java 8
42+
43+
## [0.5.5] - 2023-11-03
44+
### Changed
45+
- Allow overwrite of temporary directory location with `stencil.tmpdir` environment variable.
46+
47+
## [0.5.4] - 2023-10-11
48+
### Changed
49+
- Introduce `replaceLink` function #150
50+
51+
## [0.5.3] - 2023-07-22
52+
53+
## [0.5.2] - 2023-07-13
54+
### Changed
55+
- Fix: numbering definitions are copied from fragments #148
56+
- Introducing visual regression test
57+
- Refactoring parser code #144 and infix tokenizer #142
58+
59+
60+
## [0.5.1] - 2023-07-12
61+
### Changed
62+
- Introducing visual regression test
63+
- Refactoring parser code #144 and infix tokenizer #142
64+
65+
## [0.5.0] - 2022-12-02
66+
### Changed
67+
- various small refactors to improve code style and remove unused code
68+
- added extract-wordml script to help debugging issues
69+
- fix parsing issue with expressions in form of `x[y] - z`
70+
- fix issue with nonbreaking spaces not being trimmed [#141]
71+
- first steps for more meaningful error messages [#140]
72+
73+
## [0.4.7] - 2022-08-08
74+
### Changes
75+
- Fix: make it possible to call custom functions from fragments
76+
- Fix several linter warnings in the Clojure code base
77+
- Introduce Specs for internal data model #83
78+
79+
## [0.4.6] - 2022-07-25
80+
### Changes
81+
- Fix bug in merger substring expressions #135
82+
- Fix bug in fragment handling #136
83+
84+
## [0.4.5] - 2022-07-21
85+
### Features
86+
- Add new `replace()` function #134
87+
### Changed
88+
- Add unit tests for `coalesce` function
89+
- Bump `junit` version to `4.13.2`
90+
91+
## [0.4.4] - 2022-06-09
92+
### Changed
93+
- Fix precision of `decimal()` and `format()` functions to 8 digits
94+
95+
## [0.4.3] - 2022-06-01
96+
### Features
97+
- Introduce the `foreach` loop construct #129
98+
- Introduce the `pageBreak` function #126
99+
100+
101+
## [0.4.2] - 2022-05-04
102+
### Changed
103+
- service: fix division error on non-terminating decimal expansion due to BigDecimal usage in service.
104+
105+
## [0.4.1] - 2022-04-21
106+
### Changed
107+
- service: update dockerfile to use debian:10-slim
108+
- service: update clojure, slf4j versions
109+
- chore: some simplifications
110+
111+
## [0.4.0] - 2022-02-15
112+
### Changed
113+
- service: add js engine [#114]
114+
- core: introduce more transducers
115+
- core: `html()` function supports uppercase tags [#113]
116+
- core: newlines are kept in str substitution [#111]

README.md

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Stencil Template Engine
22

33
Stencil is an open source templating engine that transforms Office Open XML documents (mostly Microsoft
4-
Office's Word `.docx` files) from Java programs. It has a simple syntax and no programming is needed to write document templates.
4+
Office's Word `.docx` files) from the JVM. It has a simple syntax and no programming is needed to write document templates.
55

66
<p align="center"><img src="https://raw.githubusercontent.com/erdos/stencil/master/docs/graphics.svg?sanitize=true" alt="stencil flow"/></p>
77

@@ -20,59 +20,81 @@ them to make your template more readable.
2020

2121
## Features
2222

23-
- Works with `docx` and `pptx` files
24-
- Simple value substitution, conditional and repeating blocks
25-
- Substituting HTML text for dynamic text formatting
26-
- Dynamically replace images and links in the template
27-
- Show/hide rows and columns in tables
23+
- 📄 **Multiple Formats:** Works with `docx` and `pptx` files
24+
- 💻 **Simple syntax:** For value substitution, conditional and repeating blocks
25+
- 🔧 **Extendable:** Dozens of [built-in functions](https://stencil.erdos.dev/Functions.html) callable from the template
26+
- 📰 **Dynamic content:** Substituting HTML text for dynamic text formatting
27+
- 🌄 **Images and links:** Dynamically replace images and links in the template
28+
- 👀 **Tables:** Show/hide rows and columns in tables
29+
- 📐 **Programmable:** Offers API for Java and Clojure. Deployable as a Docker container.
2830

29-
## Getting Started with the Library
31+
## 📖 Getting Started with the Library
3032

3133
- See the [Example templates](examples)
3234
- Read the [Documentation](https://stencil.erdos.dev)
33-
- Read about the [Java API](docs/GettingStarted.md#java-api) and the [Clojure API](docs/GettingStarted.md#clojure-api).
35+
- Reference the [Java API](docs/GettingStarted.md#java-api) and the [Clojure API](docs/GettingStarted.md#clojure-api).
3436

35-
36-
## Getting Started with the Service
37+
## 🐳 Getting Started with the Service
3738

3839
The project has a simple [service implementation](https://github.com/erdos/stencil/tree/master/service), which is available on GitHub Packages as a [Container image](https://github.com/users/erdos/packages/container/package/stencil).
3940

4041

41-
## Version
42+
## 👉 Version
43+
44+
**Latest stable** version is `0.6.2`
45+
46+
**Latest snapshot** version is `0.6.3-SNAPSHOT`
4247

43-
**Latest stable** version is `0.6.1`
48+
Previous versions are available on the [Stencil Clojars](https://clojars.org/io.github.erdos/stencil-core) page.
4449

45-
**Latest snapshot** version is `0.6.2-SNAPSHOT`
50+
<details>
51+
<summary><b>For Java with Maven</b></summary>
4652

47-
If you are using Maven, add the followings to your `pom.xml`:
53+
If you are using Maven, add the followings to your `pom.xml`:
4854

49-
The dependency:
55+
1. The dependency:
5056

5157
``` xml
5258
<dependency>
5359
<groupId>io.github.erdos</groupId>
5460
<artifactId>stencil-core</artifactId>
55-
<version>0.6.1</version>
61+
<version>0.6.2</version>
5662
</dependency>
5763
```
5864

59-
And the [Clojars](https://clojars.org) repository:
65+
2. And the [Clojars](https://clojars.org) repository:
6066

6167
``` xml
6268
<repository>
6369
<id>clojars.org</id>
6470
<url>https://repo.clojars.org</url>
6571
</repository>
66-
```
72+
```
73+
</details>
6774

68-
Alternatively, if you are using Leiningen, add the following to
69-
the `:dependencies` section of your `project.clj`
70-
file: `[io.github.erdos/stencil-core "0.6.1"]`
75+
<details>
76+
<summary><b>For Java with Gradle</b></summary>
77+
78+
Add to the `dependencies` section of your `build.gradle` file: `implementation('io.github.erdos/stencil-core:0.6.2')`
79+
</details>
80+
81+
<details>
82+
<summary><b>For Clojure with Leiningen</b></summary>
83+
84+
If you are using Leiningen, add the following to the `:dependencies` section of your `project.clj` file:
85+
86+
`[io.github.erdos/stencil-core "0.6.2"]`
87+
</details>
88+
89+
<details>
90+
<summary><b>For Clojure with deps.edn</b></summary>
91+
92+
Add `io.github.erdos/stencil-core {:mvn/version "0.6.2"}`
93+
</details>
7194

72-
Previous versions are available on the [Stencil Clojars](https://clojars.org/io.github.erdos/stencil-core) page.
7395

7496

75-
## License
97+
## 😎 License
7698

7799
Copyright (c) Janos Erdos. All rights reserved. The use and distribution terms
78100
for this software are covered by the Eclipse Public License 2.0

build.clj

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,8 @@
8585
(println "Built JAR file")
8686
opts)
8787

88-
(defn install [opts]
89-
(jar opts)
90-
(b/install {:basis basis
91-
:lib lib
92-
:version version
93-
:jar-file jar-file-name
94-
:class-dir jar-content})
95-
opts)
96-
9788
(defn java-test [_]
89+
#_{:clj-kondo/ignore [:inline-def]} ; TODO: extract to delayed top level form
9890
(def basis (b/create-basis {:project "deps.edn" :aliases [:junit]}))
9991

10092
(println "Running Java test cases")
@@ -119,7 +111,10 @@
119111
(println "Done"))
120112

121113
(defn uber [opts]
122-
(jar opts)
114+
(jar opts)
115+
(b/compile-clj {:basis basis
116+
:ns-compile '[stencil.process stencil.api]
117+
:class-dir jar-content})
123118
(b/uber {:class-dir jar-content
124119
:uber-file uber-file-name
125120
:basis basis

deps.edn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
org.slf4j/slf4j-api {:mvn/version "2.0.9"}}
44
:paths ["src" "target/classes"]
55
:aliases
6-
{:stencil/version "0.6.2-SNAPSHOT"
6+
{:stencil/version "0.6.2"
77

88
:build
99
{:deps {org.clojure/clojure {:mvn/version "1.12.0-beta1"}

service/project.clj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
(defproject io.github.erdos/stencil-service "0.6.2-SNAPSHOT"
1+
(defproject io.github.erdos/stencil-service "0.6.2"
22
:description "Web service for the Stencil templating engine"
33
:url "https://github.com/erdos/stencil"
44
:license {:name "Eclipse Public License - v 2.0"
55
:url "https://www.eclipse.org/legal/epl-2.0/"}
66
:dependencies [[org.clojure/clojure "1.11.1"]
7-
[io.github.erdos/stencil-core "0.6.2-SNAPSHOT"]
7+
[io.github.erdos/stencil-core "0.6.2"]
88
[org.slf4j/slf4j-api "2.0.9"]
99
[org.mozilla/rhino-engine "1.7.14"]
1010
[http-kit "2.7.0"]

src/stencil/api.clj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
"A simple public API for document generation from templates."
33
(:require [clojure.walk :refer [stringify-keys]]
44
[clojure.java.io :as io]
5-
[stencil.fs :as fs]
6-
[stencil.types])
5+
[stencil.fs :as fs])
76
(:import [io.github.erdos.stencil API PreparedFragment PreparedTemplate TemplateData]
87
[java.nio.file Path]
98
[java.util Map]))
@@ -80,6 +79,5 @@
8079
:else (throw (ex-info "Unexpected object to clean up!" {:template template})))
8180
template)
8281

83-
(defmacro get-version [] (slurp (io/resource "stencil-version")))
82+
(defmacro get-version ^:private [] (slurp (io/resource "stencil-version")))
8483
(def version (doto (get-version) (assert)))
85-
(ns-unmap *ns* 'get-version)

src/stencil/cleanup.clj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
88
valid XML String -> tokens -> Annotated Control AST -> Normalized Control AST -> Evaled AST -> Hiccup or valid XML String
99
"
10-
(:require [stencil.util :refer [mod-stack-top-conj mod-stack-top-last parsing-exception stacks-difference-key]]
11-
[stencil.types :refer [open-tag close-tag]]))
10+
(:require [stencil.util :refer [mod-stack-top-conj mod-stack-top-last parsing-exception stacks-difference-key
11+
open-tag close-tag]]))
1212

1313
(set! *warn-on-reflection* true)
1414

15-
(defmulti tokens->ast-step (fn [stack token] (:cmd token)))
15+
(defmulti tokens->ast-step (fn [_stack token] (:cmd token)))
1616

1717
(defmethod tokens->ast-step :cmd/if [stack token] (conj (mod-stack-top-conj stack token) []))
1818
(defmethod tokens->ast-step :cmd/for [stack token] (conj (mod-stack-top-conj stack token) []))
@@ -54,20 +54,20 @@
5454

5555
(defn- nested-tokens-fmap-postwalk
5656
"Depth-first traversal of the tree."
57-
[f-cmd-block-before f-cmd-block-after f-child node]
57+
[pre-visit post-visit visit node]
5858
(assert (map? node))
5959
(letfn [(children-mapper [children]
6060
(mapv update-blocks children))
6161
(update-children [node]
6262
(update node ::children children-mapper))
6363
(visit-block [block]
64-
(-> block f-cmd-block-before update-children f-cmd-block-after))
64+
(-> block pre-visit update-children post-visit))
6565
(blocks-mapper [blocks]
6666
(mapv visit-block blocks))
6767
(update-blocks [node]
6868
(if (:cmd node)
6969
(update node ::blocks blocks-mapper)
70-
(f-child node)))]
70+
(visit node)))]
7171
(update-blocks node)))
7272

7373
(defn annotate-environments

0 commit comments

Comments
 (0)