#mdbook #open #preprocessor

bin+lib mdbook-open-on-gh

mdbook preprocessor to add a open-on-github link on every page

14 stable releases

new 2.2.0 Jul 6, 2022
2.0.2 Jan 26, 2022
2.0.1 Jun 11, 2021
2.0.0 Feb 24, 2021
1.0.1 Jan 30, 2020
Download history 126/week @ 2022-03-16 83/week @ 2022-03-23 71/week @ 2022-03-30 80/week @ 2022-04-06 58/week @ 2022-04-13 62/week @ 2022-04-20 128/week @ 2022-04-27 119/week @ 2022-05-04 224/week @ 2022-05-11 90/week @ 2022-05-18 133/week @ 2022-05-25 153/week @ 2022-06-01 73/week @ 2022-06-08 51/week @ 2022-06-15 43/week @ 2022-06-22 36/week @ 2022-06-29

229 downloads per month
Used in mdbook-dtmo

MPL-2.0 license

24KB
202 lines

mdbook-open-on-gh

A preprocessor for mdbook to add a open-on-github link on every page.

It adds an "Edit this file on GitHub" link on the bottom of every page, linking directly to the source file. It uses the configured git-repository-url as the base.

Installation

If you want to use only this preprocessor, install the tool:

cargo install mdbook-open-on-gh

Add it as a preprocessor to your book.toml:

[preprocessor.open-on-gh]
command = "mdbook-open-on-gh"
renderer = ["html"]

Configuration

mdbook-open-on-gh is configured using additional options under [output.html]:

[output.html]
# Required: Your repository URL used in the link.
git-repository-url = "https://github.com/$user/$project"

# Your git branch. Defaults to `main`
git-branch = "main"

# The text to use in the footer.
# The link text is marked by `[]`
open-on-text = "Found a bug? [Edit this page on GitHub.]"

To style the footer add a custom CSS file for your HTML output:

[output.html]
additional-css = ["open-in.css"]

And in open-in.css style the <footer> element or directly the CSS element id open-on-gh:

footer {
  font-size: 0.8em;
  text-align: center;
  border-top: 1px solid black;
  padding: 5px 0;
}

This code block shrinks the text size, center-aligns it under the rest of the content and adds a small horizontal bar above the text to separate it from the page content.

Finally, build your book as normal:

mdbook path/to/book

License

MPL. See LICENSE.
Copyright (c) 2020-2022 Jan-Erik Rediger janerik@fnordig.de

Dependencies

~10MB
~186K SLoC