# retext-directionality

> Detect directionality (left-to-right, right-to-left) in Retext

Latest version **1.0.0** (published 2015-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install retext-directionality
pnpm add retext-directionality
yarn add retext-directionality
bun add retext-directionality
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-08-01 |
| First published | 2014-06-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | Titus Wormer |
| Maintainers | wooorm |
| Keywords | directionality, rtl, ltr, retext |

## Links

- npm: https://www.npmjs.com/package/retext-directionality
- Repository: https://github.com/wooorm/retext-directionality
- Homepage: https://github.com/wooorm/retext-directionality#readme
- Issues: https://github.com/wooorm/retext-directionality/issues
- npm.io page: https://npm.io/package/retext-directionality

## Dependencies (3)

- [direction](https://npm.io/package/direction.md) ^0.1.5
- [nlcst-to-string](https://npm.io/package/nlcst-to-string.md) ^0.1.5
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2015-08-01
- 0.1.8 — 2015-01-18
- 0.1.7 — 2014-12-09
- 0.1.6 — 2014-11-21
- 0.1.5 — 2014-10-27
- 0.1.4 — 2014-10-21
- 0.1.3 — 2014-10-15
- 0.1.2 — 2014-09-26
- 0.1.1 — 2014-07-22
- 0.1.0 — 2014-07-12
- 0.0.4 — 2014-06-19
- 0.0.3 — 2014-06-17
- 0.0.1 — 2014-06-05

## README

# retext-directionality [![Build Status](https://img.shields.io/travis/wooorm/retext-directionality.svg)](https://travis-ci.org/wooorm/retext-directionality) [![Coverage Status](https://img.shields.io/codecov/c/github/wooorm/retext-directionality.svg)](https://codecov.io/github/wooorm/retext-directionality)

[**retext**](https://github.com/wooorm/retext "Retext") directionality
detection.

## Installation

[npm](https://docs.npmjs.com/cli/install):

```bash
npm install retext-directionality
```

**retext-directionality** is also available for [bower](http://bower.io/#install-packages),
[component](https://github.com/componentjs/component), and
[duo](http://duojs.org/#getting-started), and as an AMD, CommonJS, and globals
module, [uncompressed](retext-directionality.js) and
[compressed](retext-directionality.min.js).

## Usage

```js
var retext = require('retext');
var inspect = require('unist-util-inspect');
var direction = require('retext-directionality');

retext().use(direction).use(function () {
    return function (cst) {
        console.log(inspect(cst));
    };
}).process('A simple, Anglais, بسيطة.');
```

Yields:

```text
RootNode[1] [data={"direction":"neutral"}]
└─ ParagraphNode[1] [data={"direction":"neutral"}]
   └─ SentenceNode[10] [data={"direction":"neutral"}]
      ├─ WordNode[1] [data={"direction":"ltr"}]
      │  └─ TextNode: 'A' [data={"direction":"ltr"}]
      ├─ WhiteSpaceNode: ' ' [data={"direction":"neutral"}]
      ├─ WordNode[1] [data={"direction":"ltr"}]
      │  └─ TextNode: 'simple' [data={"direction":"ltr"}]
      ├─ PunctuationNode: ',' [data={"direction":"neutral"}]
      ├─ WhiteSpaceNode: ' ' [data={"direction":"neutral"}]
      ├─ WordNode[1] [data={"direction":"ltr"}]
      │  └─ TextNode: 'Anglais' [data={"direction":"ltr"}]
      ├─ PunctuationNode: ',' [data={"direction":"neutral"}]
      ├─ WhiteSpaceNode: ' ' [data={"direction":"neutral"}]
      ├─ WordNode[1] [data={"direction":"rtl"}]
      │  └─ TextNode: 'بسيطة' [data={"direction":"rtl"}]
      └─ PunctuationNode: '.' [data={"direction":"neutral"}]
```

## API

None, **retext-directionality** automatically detects the direction of each
[`Text`](https://github.com/wooorm/nlcst#text) (using
[**wooorm/direction**](https://github.com/wooorm/direction)), either `"ltr"`,
`"rtl"`, or `"neutral"`), and stores the direction in `node.data.direction`.

All parents (such as words, sentences, paragraphs, root) also receive a
`direction` property (`parent.data.direction`): If every
[`Text`](https://github.com/wooorm/nlcst#text) inside a parent has the same
(or neutral) direction, the parent has the same direction, otherwise, the
parent has a neutral direction.

## License

[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)

---
_Source: https://npm.io/package/retext-directionality · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
