Skip to content

Only convert exactly three dots into ellipses #14

@cocoliliace

Description

@cocoliliace

Initial checklist

Affected package

[email protected]

Steps to reproduce

import {retext} from 'retext'
import retextSmartypants from 'retext-smartypants'

const file = await retext()
  .use(retextSmartypants)
  .process('...."')

console.log(String(file))

Actual behavior

All 4 dots are converted to a single ellipsis.

Expected behavior

3 dots should be sufficient to form an ellipsis. Additional dots should not be merged into the same ellipsis.

The use case is when we use ellipsis at the end of a sentence and need a period right after it. Currently there's no way to express it with retext-smartypants.

This punctuation style is defined here:

The same issue has been opened before in #9 but that issue contained other problems and was closed with only the other problems resolved.

I can help implement it if no one else wants to, but I'm not sure how we want to go about supporting this. Here are some ways I thought of:

  1. change the behaviour of 'spaced', 'unspaced', and true to only convert 3 dots a time. This would be a breaking change to anyone currently using more than 3 dots for ellipsis, but idk if anyone does that
  2. add a '3dots' option to ellipses. This would guarantee backwards compatibility but make the config harder to maintain, becuase it's not exclusive with the 'spaced' and 'unspaced' options, so we would likely need a '3dots-spaced' and '3dots-unspaced', which would get doubled again when there's another non-exclusive option in the future
  3. change the type of ellipses to an object with space and 3dots each being a boolean field. This would be a breaking change but we can overload the option to continue supporting strings | null | undefined
  4. Add a new boolean field like ellipsis-3dots and keep the current one. Backwards compatible but would probably make the API too complex

I'm thinking 1 or 3. 1 if the assumption that nobody uses more than 3 dots for ellipses is reasonable or if we are fine with a small breaking change for those users. 3 otherwise.

The name 3dots might not be the best too

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions