Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generation of HTML documents with custom CSS #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ load(":toolchain.bzl", "pandoc_toolchain")
load(":pandoc.bzl", "PANDOC_EXTENSIONS", "pandoc")

exports_files(["README.md"])
exports_files(["stylesheet.css"])

# Precompiled Pandoc binaries provided by upstream.

Expand Down
5 changes: 4 additions & 1 deletion pandoc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ def _pandoc_impl(ctx):
cli_args.extend(["--from", ctx.attr.from_format])
if ctx.attr.to_format:
cli_args.extend(["--to", ctx.attr.to_format])
if ctx.attr.css and PANDOC_EXTENSIONS[ctx.attr.to_format] == "html":
cli_args.extend(["-css", ctx.file.css.path])
cli_args.extend(["-o", ctx.outputs.output.path])
cli_args.extend([ctx.file.src.path])
ctx.actions.run(
mnemonic = "Pandoc",
executable = toolchain.pandoc.files.to_list()[0].path,
arguments = cli_args,
inputs = depset(
direct = ctx.files.src,
direct = ctx.files.src + ctx.files.css,
transitive = [toolchain.pandoc.files],
),
outputs = [ctx.outputs.output],
Expand All @@ -75,6 +77,7 @@ _pandoc = rule(
"from_format": attr.string(),
"options": attr.string_list(),
"src": attr.label(allow_single_file = True, mandatory = True),
"css": attr.label(allow_single_file = True, mandatory = False),
"to_format": attr.string(),
"output": attr.output(mandatory = True),
},
Expand Down
1 change: 1 addition & 0 deletions sample/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("//:pandoc.bzl", "PANDOC_EXTENSIONS", "pandoc")
[pandoc(
name = "readme_" + fmt,
src = "//:README.md",
css = "//:stylesheet.css",
from_format = "markdown",
to_format = fmt,
) for fmt in PANDOC_EXTENSIONS.keys()]
Expand Down
9 changes: 9 additions & 0 deletions stylesheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<style type="text/css">
html, body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.4;
color: #333;
background-color: #eee;
}
</style>