<commit_before># Bindery.js

## About

bindery.js is a questionably useful library for producing book layouts in the
browser. The core library flows text content over multiple pages. It also includes modules for common book elements, including numbering, running headers, out-of-flow spreads, and more. The modules can be applied in order to map web conventions to print conventions,
like displaying hyperlink destinations as footnotes.

The resulting book is viewable in-browser, and can open the system ⌘P dialog to send to a printer or to PDF


## Who is this for?

The goal of bindery.js is to provide an approachable jumping-off point for HTML-to-Print
exploration. Because of this, it works out of the box (without needing to run a dev server,
set up a development environment, or use preprocessors).

If you are interested in integrating it into a larger project, please feel free to reach out.


## Background

bindery.js was originally written in Spring 2014 for [for/with/in](http://htmloutput.risd.gd/),
a publication from participants in "HTML Output" at RISD. It consisted mostly of a series of hacks written in jQuery on top of [Rem<NAME>is's CSS
Regions polyfill](https://github.com/FremyCompany/css-regions-polyfill), but it was enough
to publish a book without touching inDesign.

In 2016, [<NAME>](http://cath.land) and [<NAME>](http://ltwp.net) adapted the code into an easy-to-use [Jekyll](https://jekyllrb.com/) theme for
the Design Office, under the name [Baby Bindery](https://github.com/thedesignoffice/babybindery).

As of February 2017, it is in the process of being rewritten as a usable, modular library (and without a dependency on jQuery or a polyfill for the [much-maligned CSS Regions spec](https://alistapart.com/blog/post/css-regions-considered-harmful)).

## Getting started

```html
<html>
  <div class="content">
    <!-- The whole content of your book -->
  </div>

  <script src="./bindery.js"></script>
  <script>
    let binder = new Bindery({
      source: ".content",
      pageSize: { height: 500, width: 350 },
      rules: [
        Bindery.BreakBefore({ selector: "h2" }),
        Bindery.RunningHeader({ selector: "h2" }),
        Bindery.PageNumber(),
      ],
    });

    binder.makeBook();
  </script>
</html>

```

## Docs

TK

## To Do

- [x] Page Number references (Tables of Contents, Indexes)
- [ ] More control over spreads, ordering, booklet printing
- [x] Customizable page sizing
- [ ] Examples for use with blogging platforms
- [ ] Wrapper for use with React.
- [ ] Approachable API for writing custom rules
- [ ] Documentation!
- [ ] Make usable<commit_msg>First pass at documentation<commit_after># Bindery.js

## About

bindery.js is a library for producing book layouts in the browser. The core library allows your HTML to flow over multiple pages, and provides an interface to preview and configure the resulting book. Bindery includes plugins that can express numbering, running headers, spreads, footnotes, tables of contents, and more. With just a couple lines of code, you can [convert URLs to footnotes](https://github.com/evnbr/bindery/tree/master/example), [generate fore-edge printing](https://github.com/evnbr/bindery/tree/master/example), [dynamic font sizes](https://github.com/evnbr/bindery/tree/master/example), [convert a video into a flipbook](https://github.com/evnbr/bindery/tree/master/example), and more.

#### Background

bindery.js was originally written in Spring 2014 for [for/with/in](http://htmloutput.risd.gd/),
a publication from participants in "HTML Output" at RISD. It consisted mostly of a series of hacks written in jQuery on top of [Remy Francois's CSS
Regions polyfill](https://github.com/FremyCompany/css-regions-polyfill), but it was enough
to publish a book without touching inDesign.

In 2016, [<NAME>](http://cath.land) and [<NAME>](http://ltwp.net) adapted the code into an easy-to-use [Jekyll](https://jekyllrb.com/) theme for
the Design Office, under the name [Baby Bindery](https://github.com/thedesignoffice/babybindery).

As of February 2017, it is in the process of being rewritten as a usable, modular library (and without a dependency on jQuery or a polyfill for the [much-maligned CSS Regions spec](https://alistapart.com/blog/post/css-regions-considered-harmful)).

## Getting started

```html
<html>
  <div class="content">
    <!-- The whole content of your book -->
  </div>

  <script src="./bindery.js"></script>
  <script>
    let binder = new Bindery({
      source: ".content",
      rules: [
        Bindery.BreakBefore({ selector: "h2" }),
        Bindery.RunningHeader({ selector: "h2" }),
        Bindery.PageNumber(),
      ],
    });

    binder.makeBook();
  </script>
</html>

```

## Docs

#### Setup Options
- **`source:`**
  - Which content to flow across pages.
  - If the content is on the same page, use a CSS selector. You can also use a reference to the node.
  - If the content must be fetched from a remote page, pass an object in the form of { url, selector}.
```js
// Selector
let binder = new Bindery({
  source: '#content',
});

// Node
let binder = new Bindery({
  source: document.getElementByID('content'),
});

// Fetch
let binder = new Bindery({
  source: {
    selector: '#content',
    url: '/posts.html'
});
```

  
- **`pageUnit: `**
  - String representing units. Should be one of the following: `'px'`, `'pt'`, `'pc'`, `'in'`, `'cm'`, `'mm'`
  - Default: `'in'`
  
- **`pageSize:`**
  - Size of page, in pageUnits { width: Number, height: Number }
  - Default: `{ width: 4, height: 6 }`
  
- **`pageMargin:`**
  - Size of margins, in pageUnits { top: Number, inner: Number, outer: Number, bottom: Number }
  - Default:  `{  top: 0.25, inner: 0.25, outer: 0.25, bottom: 0.25, }`
  
 ```js
let binder = new Bindery({
  source: '#content',
  pageUnit: 'pt',
  pageSize: { height: 500, width: 350 },
  pageMargin: { top: 20, bottom: 40, inner: 20, outer: 30 },
});
```
 
  
- **`standalone:`**
  - Boolean. When this is set to true, bindery will run automatically and not show a Done button. This is useful if you want to locate the book at its own url, ie "example.com/book.html".
  - Default: false

- **`startingViewMode: `**
  - Should be one of the following:
    - `'grid'` - Default
    - `'interactive'` - Interactive 3D Book
    - `'print'` - Print preview, showing sheet with crop marks and bleed

- **`rules:`**
  - An array of Rules. Use Rules to set up a page based on what content ends up on it. 
  - Default: `[]` (No rules applied)

#### Rules

- BreakBefore
- Footnote
- FullPage
- Spread
- PageReference
- RunningHeader

#### Creating Custom Rules

TK

## Developing

Written in ES6, built with babel, bundled with webpack. The only dependency is [Hyperscript](https://github.com/hyperhype/hyperscript), for templating the UI, which is included in the bundle by default.

The goal of bindery.js is to provide an approachable jumping-off point for HTML-to-Print exploration. Because of this, it is intended to work out of the box as a script tag (without needing to run a dev server, set up a development environment, use preprocessors, or really know javascript at all).

- `npm run-script build` - Update build/bindery.js
- `npm run-script buildProd` - Update build/bindery.min.js
- `npm run-script lint:js` - Run ESLint, using the [Airbnb style guide](https://github.com/airbnb/javascript)

#### To Do

- [x] Page Number references (Tables of Contents, Indexes)
- [ ] More control over spreads, ordering, booklet printing
- [x] Customizable page sizing
- [ ] Examples for use with blogging platforms
- [ ] Wrapper for use with React.
- [ ] Approachable API for writing custom rules
- [ ] Documentation!
{'fraction_non_alphanumeric': 0.12102657634184472, 'fraction_numerical': 0.008337675872850442, 'mean_word_length': 3.7185003073140748, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '584575', 'n_tokens_mistral': 2416, 'n_tokens_neox': 2299, 'n_words': 925}