Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/appleple/document-outliner

HTML5 outliner
https://github.com/appleple/document-outliner

markup npm

Last synced: 5 days ago
JSON representation

HTML5 outliner

Awesome Lists containing this project

README

        

# document-outliner
[![npm version](https://badge.fury.io/js/document-outliner.svg)](https://badge.fury.io/js/document-outliner)
[![CircleCI](https://circleci.com/gh/appleple/document-outliner/tree/master.svg?style=shield)](https://circleci.com/gh/appleple/document-outliner/tree/master)
[![npm download](http://img.shields.io/npm/dm/document-outliner.svg)](https://www.npmjs.com/package/document-outliner)
[![GitHub license](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://raw.githubusercontent.com/appleple/document-outliner/master/LICENSE)

A utility to make ol/ul list by using html5 outline algorithm.

**Specifications**

> [Living Standard — Last Updated 11 December 2018](https://html.spec.whatwg.org/multipage/sections.html#outlines)

## Installation

### Vanilla (Plain JavaScript)

#### via npm

```sh
npm install document-outliner
```

#### via yarn

```sh
yarn add document-outliner
```

#### vid cdn

```html

```

### jQuery plugin

#### via cdn

```html

```

## Usage

### Vanilla (Plain JavaScript)

```javascript
import DocumentOutliner from 'document-outliner';

const outliner = new DocumentOutliner('.js-outline-src');
outliner.makeList('.js-outline-output', {listType: 'ul'});
```

### jQuery

```javascript
$(function () {
$('.container').documentOutliner('.output', {link: false});
});
```

## Options

| name | description | default |
|:---|:---|:---|
| link | create HTML anchor link | true |
| listType | HTML list type ('ol'|'ul') | 'ol' |
| listClassName | ol/ul class name | '' |
| itemClassName | li class name | '' |
| linkClassName | link class name | '' |
| anchorName | anchor link name ($1 is to be link number) | 'heading-$1' |
| levelLimit | limit on number of level | 99 |

## Example

**HTML**

```html


The Tax Book



Earning money


Earning money is good.



Getting a job


To earn money you typically need a job.





Spending money


Spending is what money is mainly used for.



Cheap things


Buying cheap things often not cost-effective.




Expensive things


The most expensive thing is often not the most cost-effective either.





Investing money


You can lend your money to other people.




Losing money


If you spend money or invest money, sooner or later you will lose money.



Poor judgement


Usually if you lose money it's because you made a mistake.





```

**JavaScript**

```javascript
const outliner = new DocumentOutliner('.container');
outliner.makeList('.outline', {
link: true,
listType: 'ul',
listClassName: 'list-group',
itemClassName: 'list-group-item',
anchorName: 'heading-$1'
});
```

**Yield**

```html


The Tax Book



Earning money


Earning money is good.



Getting a job


To earn money you typically need a job.





Spending money


Spending is what money is mainly used for.



Cheap things


Buying cheap things often not cost-effective.




Expensive things


The most expensive thing is often not the most cost-effective either.





Investing money


You can lend your money to other people.




Losing money


If you spend money or invest money, sooner or later you will lose money.



Poor judgement


Usually if you lose money it's because you made a mistake.





```

## Licence

[MIT](https://github.com/appleple/document-outliner/blob/master/LICENSE)