Skip to content
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
dist/
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
SOURCES := $(shell find src -type f -name '*.md')
TARGETS := $(patsubst src/%.md,docs/%.html,$(SOURCES))

CARGO ?= cargo
TARGET ?= x86_64-unknown-linux-musl
CARGO_TARGET_DIR ?= $(CURDIR)/target

.PHONY: all
all: docs/.nojekyll $(TARGETS)

Expand All @@ -38,4 +42,20 @@ docs: docs/.nojekyll
docs/%.html: src/%.md template.html5 Makefile tools/build.sh
tools/build.sh "$<" "$@"

### Makefile commands for rust wrapper

# Build rust wrapper
.PHONY: pandoc-pretty
pandoc-pretty: dist/pandoc-pretty

dist/pandoc-pretty: pandoc-pretty/src/main.rs pandoc-pretty/Cargo.toml template.html5 docs/css/theme.css docs/css/skylighting-solarized-theme.css pandoc-sidenote.lua
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) build --release --target $(TARGET) --manifest-path pandoc-pretty/Cargo.toml
mkdir -p dist
cp $(CARGO_TARGET_DIR)/$(TARGET)/release/pandoc-pretty dist/pandoc-pretty

# run tests for rust wrapper
.PHONY: test-pandoc-pretty
test-pandoc-pretty:
CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) test --manifest-path pandoc-pretty/Cargo.toml --tests

### End Makefile commands for rust wrapper
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,49 @@ make watch

More instructions in the [Usage][Usage] section of the website above.

## Native helper binary

You can optionally build a static helper that wraps your local `pandoc` with this
repo’s template, CSS, and sidenote filter baked in. This allows you to trivially
convert markdown files to html anywhere on your system with a single command, such as:

```bash
pandoc-pretty README.md
```

Which will spit out a README.html file you can open in your browser or deploy to the web.

You can optionally specify output location and name:

```bash
pandoc-pretty README.md ~/README-weird-name.html
```

### Building the native wrapper

This binary is a small rust-based wrapper that requires `pandoc` to be installed and
available in your `PATH` variable. Install and init `rustup`, then:

```bash
rustup target add x86_64-unknown-linux-musl # once
make pandoc-pretty # produces dist/pandoc-pretty
```

You may wish to copy the binary somewhere on you system in `PATH`. For example:

```bash
# If you have ~/bin/
cp ./dist/pandoc-pretty ~/bin/

# Alternatively
sudo cp ./dist/pandoc-pretty /usr/local/bin/
```

Usage: `pandoc-pretty input.md [output.html]` (requires `pandoc` in `PATH`). The
output defaults to the input filename with `.html` extension. The
output HTML is self-contained: template, CSS, and sidenote Lua filter are
embedded so the file works standalone.

[Usage]: https://jez.io/pandoc-markdown-css-theme/#usage

## License
Expand Down
Loading