Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ sile/readme_%.sil: sile/README.md $(CODEBLOCK_FILTER)

TYPSTASSETS = typst/decasify.wasm typst/readme_1.svg typst/readme_2.svg typst/LICENSE

TYPST_EXPECTATIONS = tests/styled.html

.PHONY: typst-universe
typst-universe: $(TYPSTASSETS)

Expand All @@ -111,8 +113,13 @@ typst/decasify.wasm: typst/src/lib.rs
$(TYPST) compile -f svg $< $@
$(SVGO) --multipass --precision 2 --pretty --indent 2 $@

%.html: %.typ typst-universe
$(TYPST) compile --root $(top_srcdir) --features html --format html $<

SILEASSETS = sile/readme_1.svg sile/readme_2.svg

SILE_EXPECTATIONS = tests/styled.txt

.PHONY: sile-docs
sile-docs: $(SILEASSETS)

Expand All @@ -122,16 +129,24 @@ sile-docs: $(SILEASSETS)
%.pdf: %.sil
cp $< target/
cd target
$(SILE) $(<F) -o ../$@
$(SILE) -o ../$@ $(<F)

%.svg: %.pdf
$(PDF2SVG) $< $@
$(SVGO) --multipass --precision 2 --pretty --indent 2 $@
$(SED) -i -e '/\/defs/a <rect width="100%" height="100%" fill="white" />' $@

check: busted pytest
%.txt: %.sil sile-docs
cp $< target/
cd target
$(SILE) -b debug -o ../$@ $(<F)
$(SILE) $(<F)

PHONY_DEVELOPER_TARGETS = rockspecs srcrocks rocks install-luarock busted pytest release-preview
TESTS = tests/style.html

check: busted pytest sile-test typst-test

PHONY_DEVELOPER_TARGETS = rockspecs srcrocks rocks install-luarock busted pytest sile-test typst-test release-preview
.PHONY: $(PHONY_DEVELOPER_TARGETS)

if DEVELOPER_MODE
Expand Down Expand Up @@ -172,6 +187,12 @@ pytest:
$(MATURIN) develop
env PYTHONPATH=.venv/lib/python3.12/site-packages/decasify $(PYTEST)

sile-test: $(SILE_EXPECTATIONS)
$(GIT) diff-files --quiet -- $^

typst-test: $(TYPST_EXPECTATIONS)
$(GIT) diff-files --quiet -- $^

define rockpec_template =
$(SED) -e "s/@""PACKAGE_NAME""@/$(PACKAGE_NAME)/g" \
-e "s/@""SEMVER""@/$(SEMVER)/g" \
Expand Down
37 changes: 37 additions & 0 deletions tests/styled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<table>
<tr>
<td>Source</td>
<td>this sample <strong>has bold</strong> and <em>italic underlined</em> bits.</td>
</tr>
</table>
<h2>Sentencecase</h2>
<table>
<tr>
<td>Actual</td>
<td>This sample <strong>has bold</strong> and <em>italic underlined</em> bits.</td>
</tr>
<tr>
<td>Expected</td>
<td>This sample <strong>has bold</strong> and <em>italic underlined</em> bits.</td>
</tr>
</table>
<h2>Titlecase</h2>
<table>
<tr>
<td>Actual</td>
<td>This Sample <strong>Has Bold</strong> and <em>Italic Underlined</em> Bits.</td>
</tr>
<tr>
<td>Expected</td>
<td>This Sample <strong>Has Bold</strong> and <em>Italic Underlined</em> Bits.</td>
</tr>
</table>
</body>
</html>
18 changes: 18 additions & 0 deletions tests/styled.sil
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
\begin{document}
\nofolios
\neverindent
\language[main=en]
\use[module=packages.rules]
\use[module=packages.decasify]
\define[command=sample]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.}
\define[command=group]{\bigskip\font[size=16pt,weight=800]{\process}\par}

\sample

\group{Sentencecase}
\decasify[case=sentence]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.}

\group{Titlecase}
\decasify[case=title]{this sample \strong{has bold} and \em{italic \underline{underlined}} bits.}

\end{document}
23 changes: 23 additions & 0 deletions tests/styled.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#import "../typst/decasify.typ": sentencecase, titlecase

#set text(lang: "en")

#let sample = [this sample *has bold* and _italic #underline[underlined]_ bits.]

#table(columns: (2cm, 9cm))[Source][#sample]

= Sentencecase

#table(columns: (2cm, 9cm))[Actual][
#sentencecase[#sample]
][Expected][
This sample *has bold* and _italic #underline[underlined]_ bits.
]

= Titlecase

#table(columns: (2cm, 9cm))[Actual][
#titlecase[#sample]
][Expected][
This Sample *Has Bold* and _Italic #underline[Underlined]_ Bits.
]