Skip to content

Commit b7b55ed

Browse files
jupblbampcode-com
andcommitted
Add comprehensive test suite and CI workflow
- Add test fixtures for various markdown scenarios - Implement bash test script with 25 test cases - Add GitHub Actions workflow for Linux testing - Use official pandoc/actions/setup for installation - Test with latest pandoc version - Include shellcheck linting - Test with pre-commit for idempotency - Add CI badge to README Co-authored-by: Amp <[email protected]> Amp-Thread-ID: https://ampcode.com/threads/T-a4b3b491-de29-4cf7-a459-f324a9c0c53b
1 parent a06400b commit b7b55ed

File tree

6 files changed

+525
-0
lines changed

6 files changed

+525
-0
lines changed

.github/workflows/test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v5
17+
18+
- name: Install pandoc
19+
uses: pandoc/actions/setup@v1
20+
21+
- name: Show pandoc version
22+
run: pandoc --version
23+
24+
- name: Run tests
25+
run: ./tests/test_pandoc_format.sh
26+
27+
- name: Test with pre-commit
28+
run: |
29+
pip install pre-commit
30+
pre-commit run --all-files || true
31+
# Run again to ensure idempotency
32+
pre-commit run --all-files
33+
34+
lint:
35+
runs-on: ubuntu-latest
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v5
40+
41+
- name: Shellcheck
42+
run: |
43+
sudo apt-get update
44+
sudo apt-get install -y shellcheck
45+
shellcheck pandoc-format
46+
shellcheck tests/test_pandoc_format.sh
47+
48+
- name: Check file permissions
49+
run: |
50+
test -x pandoc-format || (echo "pandoc-format is not executable" && exit 1)
51+
test -x tests/test_pandoc_format.sh || (echo "test script is not executable" && exit 1)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# pre-commit-pandoc
22

3+
[![Test](https://github.com/jupblb/pre-commit-pandoc/actions/workflows/test.yml/badge.svg)](https://github.com/jupblb/pre-commit-pandoc/actions/workflows/test.yml)
4+
35
A [pre-commit] hook for formatting Markdown files using [pandoc].
46

57
## Features
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Already Formatted Document
2+
3+
This document is already properly formatted with 80-column width and reference
4+
links.
5+
6+
## Section with Links
7+
8+
This paragraph contains [a properly formatted link] that already uses reference
9+
style formatting.
10+
11+
## Lists
12+
13+
- First item
14+
- Second item
15+
- Third item
16+
17+
## Code Block
18+
19+
``` bash
20+
echo "This is already formatted"
21+
```
22+
23+
[a properly formatted link]: https://example.com

tests/fixtures/complex.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Complex Markdown Document
2+
3+
This document contains various markdown elements to test comprehensive formatting.
4+
5+
## Code Blocks
6+
7+
```python
8+
def hello_world():
9+
print("Hello, World!")
10+
return True
11+
```
12+
13+
## Tables
14+
15+
| Column 1 | Column 2 | Column 3 |
16+
|----------|----------|----------|
17+
| Data 1 | Data 2 | Data 3 |
18+
| More data that is quite long | Even more data | Last column |
19+
20+
## Links and References
21+
22+
Here's [a link to GitHub](https://github.com) and [another link to Google](https://google.com).
23+
24+
We also have [repeated link to GitHub](https://github.com) that should use the same reference.
25+
26+
## Blockquotes
27+
28+
> This is a blockquote with some text that should be wrapped appropriately
29+
> when the line length exceeds the configured column width.
30+
31+
## Nested Lists
32+
33+
1. First ordered item
34+
- Nested unordered item
35+
- Another nested item with [a link](https://example.org)
36+
2. Second ordered item
37+
1. Nested ordered item
38+
2. Another nested ordered
39+
40+
## Inline Code and Emphasis
41+
42+
This paragraph contains `inline code`, *italic text*, **bold text**, and ***bold italic text***.
43+
44+
## Horizontal Rule
45+
46+
---
47+
48+
## Images
49+
50+
![Alt text for image](https://example.com/image.png "Image title")

tests/fixtures/simple.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Simple Test Document
2+
3+
This is a simple test with [inline link](https://example.com) that should be converted to reference style by default.
4+
5+
A paragraph with very long lines that exceed the default 80 character column width limit and should be wrapped appropriately when formatted by pandoc.
6+
7+
## Lists
8+
9+
- First item
10+
- Second item with [a link](https://github.com)
11+
- Third item

0 commit comments

Comments
 (0)