#mdbook #open #preprocessor #on

bin+lib mdbook-open-on-gh

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

11 stable releases

2.0.1 Jun 11, 2021
2.0.0 Feb 24, 2021
1.4.1 Jan 6, 2021
1.3.1 Sep 28, 2020
1.0.1 Jan 30, 2020
Download history 50/week @ 2021-07-03 30/week @ 2021-07-10 40/week @ 2021-07-17 64/week @ 2021-07-24 90/week @ 2021-07-31 57/week @ 2021-08-07 65/week @ 2021-08-14 78/week @ 2021-08-21 49/week @ 2021-08-28 55/week @ 2021-09-04 80/week @ 2021-09-11 86/week @ 2021-09-18 80/week @ 2021-09-25 60/week @ 2021-10-02 63/week @ 2021-10-09 67/week @ 2021-10-16

157 downloads per month
Used in mdbook-dtmo

MPL-2.0 license

22KB
147 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"]

Add a repository URL to use as a base in your book.toml:

[output.html]
git-repository-url = "https://github.com/mozilla/glean"

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 Jan-Erik Rediger janerik@fnordig.de

Dependencies

~9.5MB
~178K SLoC

N`