Skip to content

Commit

Permalink
Use perevir for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Aug 15, 2024
1 parent 5e1cc78 commit c03271d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 24 deletions.
27 changes: 3 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
# Name of the filter file, *with* `.lua` file extension.
FILTER_FILE := $(wildcard *.lua)
# Name of the filter, *without* `.lua` file extension
FILTER_NAME = $(patsubst %.lua,%,$(FILTER_FILE))

# Allow to use a different pandoc binary, e.g. when testing.
PANDOC ?= pandoc
# Allow to adjust the diff command if necessary
DIFF = diff

# Test that running the filter on the sample input document yields
# the expected output.
#
# The automatic variable `$<` refers to the first dependency
# (i.e., the filter file).
test: $(FILTER_FILE) test/input.md test/test.yaml
$(PANDOC) --defaults test/test.yaml | \
$(DIFF) test/expected.native -
# Use perevir to run the test
test: test/perevirka.md
perevir $<

# Ensure that the `test` target is run each time it's called.
.PHONY: test

# Re-generate the expected output. This file **must not** be a
# dependency of the `test` target, as that would cause it to be
# regenerated on each run, making the test pointless.
test/expected.native: $(FILTER_FILE) test/input.md test/test.yaml
$(PANDOC) --defaults test/test.yaml --output=$@
36 changes: 36 additions & 0 deletions test/perevirka.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
perevir:
filters:
- parse-latex.lua
---

The below Markdown contains LaTeX snippets to set the color of
some words, and to define a table.

``` markdown {#input}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
hendrerit \textcolor{red}{tempor tellus}. Donec pretium posuere
tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec,
purus.

\begin{tabularx}{0.8\textwidth} { l | c | r }
lorem 1 & ipsum 1 & nullus \\
\hline
lorem 2 & ipsum 2 & nullus \\
\end{tabularx}
```

Both uses of LaTeX are picked up and translated to Markdown.

> <div id="output">
>
> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec
> hendrerit [tempor tellus]{style="color: red"}. Donec pretium posuere
> tellus. Proin quam nisl, tincidunt et, mattis eget, convallis nec,
> purus.
>
> | lorem 1 | ipsum 1 | nullus |
> |:--------|:-------:|-------:|
> | lorem 2 | ipsum 2 | nullus |
>
> </div>

0 comments on commit c03271d

Please sign in to comment.