Giter Site home page Giter Site logo

retext-sentence-spacing's Introduction

retext-sentence-spacing

Build Coverage Downloads Size Sponsors Backers Chat

retext plugin to check spacing between sentences.

Contents

What is this?

This package is a unified (retext) plugin to check spacing between sentences. For example, it can check for one or two spaces sentences.

When should I use this?

You can opt-into this plugin when you’re dealing with content that might contain mistakes, and have authors that can fix that content.

Install

This package is ESM only. In Node.js (version 16+), install with npm:

npm install retext-sentence-spacing

In Deno with esm.sh:

import retextSentenceSpacing from 'https://esm.sh/retext-sentence-spacing@6'

In browsers with esm.sh:

<script type="module">
  import retextSentenceSpacing from 'https://esm.sh/retext-sentence-spacing@6?bundle'
</script>

Use

Say our document example.txt contains:

One sentence. Two sentences.

One sentence.  Two sentences.

…and our module example.js contains:

import {retext} from 'retext'
import retextSentenceSpacing from 'retext-sentence-spacing'
import {read} from 'to-vfile'
import {reporter} from 'vfile-reporter'

const file = await retext()
  .use(retextSentenceSpacing)
  .process(await read('example.txt'))

console.error(reporter(file))

…then running node example.js yields:

example.txt
3:14-3:16 warning Unexpected 2 spaces between sentence, expected 1 space space retext-sentence-spacing

⚠ 1 warning

The default is to check for 1 space, which can be changed. For example, to 2 spaces:

 const file = await retext()
-  .use(retextSentenceSpacing)
+  .use(retextSentenceSpacing, {preferred: 'double-space'})
   .process(await read('example.txt'))

…now running node example.js once again yields:

example.txt
1:14-1:15 warning Unexpected 1 space between sentence, expected 2 spaces double-space retext-sentence-spacing

⚠ 1 warning

API

This package exports no identifiers. The default export is retextSentenceSpacing.

unified().use(retextSentenceSpacing[, options])

Check spacing between sentences.

Parameters
  • options (Options, optional) — configuration
Returns

Transform (Transformer).

Options

Configuration (TypeScript type).

Fields
  • preferred ('double-space', 'newline', 'space', 0, 1, 2, default: 'space') — spaces to use

Messages

Each message is emitted as a VFileMessage on file, with source set to 'retext-sentence-spacing', ruleId to the preferred style ('newline', 'space', or 'double-space'), actual to the unexpected value, and expected to the expected value.

Types

This package is fully typed with TypeScript. It exports the additional type Options.

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, retext-sentence-spacing@^6, compatible with Node.js 16.

Related

Contribute

See contributing.md in retextjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

License

MIT © Titus Wormer

retext-sentence-spacing's People

Contributors

greenkeeperio-bot avatar remcohaszing avatar wooorm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

thomdietrich

retext-sentence-spacing's Issues

False positives with Markdown tables

Initial checklist

Affected packages and versions

5.2.0

Steps to reproduce

I forgot my markdown files with Prettier, and then use remark afterwards to validate certain things.

However, this rule does not seem to work properly with markdown tables. For example, it generates false positives for the following text:

| Priority | Category of card                                        | Reason                                                                |
| -------- | ------------------------------------------------------- | --------------------------------------------------------------------- |
| 1        | Blind-plays                                             | Demonstrating that a _Finesse_ or _Bluff_ occurred is very important. |
| 2        | Cards that lead into clued cards in someone else's hand | Otherwise, the team would lose _Tempo_.                               |
| 3        | Cards that lead into the player's own hand              | It is bad for a suit to be "held up" on one player.                   |
| 4        | 5's                                                     | Playing a 5 gets the team a free clue.                                |
| 5        | The lower rank card                                     | The smaller stacks are more important to fill up.                     |
| 6        | The left-most card                                      | The left-most card is more likely to be good.                         |

Runtime

Node v16

Package manager

yarn 1

OS

Windows

Build and bundle tools

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.