Giter VIP home page Giter VIP logo

remark-retext's Issues

Default example doesn't run

Hey Titus!

Unfortunately running into some issues with upgrading retext-mapbox-standard to the 'newest everything' and I can isolate the problem up to this module, sort of...

Here's a gist for demonstration: https://gist.github.com/tmcw/0dbd9cbcbccdd10899200cf6d00f04f5

Issues that I've been able to isolate so far:

  • The readme example on this project uses throw err for error reporting within the remark callback method, but that gets caught by unified and silenced.
  • The actual error is Error: mdast-util-to-nlcst expected node

Support string arrays like in unified-engine

Subject of the feature

It would be nice if remark-retext could support a unified plugin list instead of a processor using the same syntax as unified-engine. Logic for this resides in https://github.com/unifiedjs/unified-engine/blob/main/lib/configuration.js. It probably makes sense to extract it into a new unified project.

Problem

remark-retext is often used with remark-cli, which supports YAML and JSON configuration files, but remark-retext only works with JavaScript configuration files, because a processor is needed.

Expected behavior

It would be nice if the following .remarkrc file:

const dictionary = require('dictionary-en');
const english = require('retext-english');
const quotes = require('retext-quotes');
const repeatedWords = require('retext-repeated-words');
const syntaxURLs = require('retext-syntax-urls');
const unified = require('unified');

module.exports = {
  plugins: [
    'remark-frontmatter',
    'remark-gfm',
    'remark-lint-heading-increment',
    'remark-lint-no-duplicate-defined-urls',
    'remark-lint-no-duplicate-definitions',
    'remark-lint-no-empty-url',
    'remark-lint-no-reference-like-url',
    'remark-lint-no-undefined-references',
    'remark-lint-no-unneeded-full-reference-image',
    'remark-lint-no-unneeded-full-reference-link',
    'remark-lint-no-unused-definitions',
    'remark-prettier',
    ['remark-validate-links', { repository: 'https://gitlab.com/remcohaszing/koas.git' }],
    [
      'remark-retext',
      unified()
        .use(english)
        .use(syntaxURLs)
        .use(repeatedWords)
        .use(quotes),
    ],
  ],
};

could be rewritten as JSON or YAML:

plugins:
  - remark-frontmatter
  - remark-gfm
  - remark-lint-heading-increment
  - remark-lint-no-duplicate-defined-urls
  - remark-lint-no-duplicate-definitions
  - remark-lint-no-empty-url
  - remark-lint-no-reference-like-url
  - remark-lint-no-undefined-references
  - remark-lint-no-unneeded-full-reference-image
  - remark-lint-no-unneeded-full-reference-link
  - remark-lint-no-unused-definitions
  - remark-prettier
  - - remark-validate-links
    - repository: https://gitlab.com/remcohaszing/koas.git
  - - remark-retext
    - - retext-english
      - retext-syntax-urls
      - retext-repeated-words
      - retext-quotes

Alternatives

N/A

retext-spell error on autolink

(I'm not sure if this is the right place to report the issue, since it uses several components of the remark and retext environment, so please excuse me if it should be somewhere else.)

Subject of the issue

I'm using remark-retext to run retext-spell on the content of Markdown files, and I get a warning for a spelling error in an autolink.

Your environment

  • OS: macOS Mojave (10.14.6)
  • Packages: See package.json below
  • Env: npm 6.14.4, node v12.18.0

Steps to reproduce

Run these commands in a directory with the files below:

$ npm install
$ node index.js

package.json:

{
  "name": "remark-retext-spell-autolink",
  "version": "0.0.1",
  "license": "BlueOak-1.0.0",
  "files": [
    "index.js"
  ],
  "dependencies": {
    "dictionary-en": "3.0.0",
    "remark-parse": "8.0.2",
    "remark-retext": "4.0.0",
    "remark-stringify": "8.1.0",
    "retext-english": "3.0.4",
    "retext-spell": "4.0.0",
    "unified": "9.0.0",
    "vfile-reporter": "6.0.1"
  }
}

index.js:

'use strict'

const unified = require('unified')

unified()
  .use(require('remark-parse'))
  .use(
    require('remark-retext'),
    unified()
      .use(require('retext-english'))
      .use(require('retext-spell'), {dictionary: require('dictionary-en')})
  )
  .use(require('remark-stringify'))
  .process('<https://blueoakcouncil.org/license/1.0.0>', (err, file) => {
    console.error(require('vfile-reporter')(err || file))
  })

Expected behaviour

I expected no warning for anything in an autolink, since it will undoubtedly contain things that are not (English) words.

I'm reporting here, since I would expect remark-retext to drop autolinks when passing the text from the Markdown to the retext processor.

Actual behaviour

$ node index.js 
  1:10-1:28  warning  `blueoakcouncil.org` is misspelt  blueoakcouncil-org  retext-spell

⚠ 1 warning

remark-retext not playing nicely with retext-smartypants

I can't get retext-smartypants to do its thing when combined with remark-retext.

This works fine:

const file = unified()
  .use(require('retext-english'))
  .use(require('retext-smartypants'))
  .use(require('retext-stringify'))
  .processSync('He said, "A \'simple\' English sentence. . ."')

console.log(String(file))
// => He said, “A ‘simple’ English sentence…"

But this doesn't:

const file = unified()
  .use(require('remark-parse'))
  .use(
    require('remark-retext'),
    unified()
      .use(require('retext-english'))
      .use(require('retext-smartypants'))
  )
  .use(require('remark-stringify'))
  .processSync('He said, "A \'simple\' English sentence. . ."')

console.log(String(file))
// => He said, "A 'simple' English sentence. . ."

@wooorm am I doing something wrong?

Add option to use syncronous processor

Initial checklist

Problem

remark-retext currently returns an async processor with no option to change this.

Solution

By adding an option to request a syncronous processor instead, the plugin would become more versatile.

Alternatives

Do not use remark-retext in syncronous functions.

Example code fails with `TypeError: file.warn is not a function`

I tested the example code with nodejs v10.11.0 and v12.4.0, in both cases I get a type error

TypeError: file.warn is not a function
    at warn ($MYWORKDIR/node_modules/retext-equality/lib/index.js:268:18)
    at Object.simple ($MYWORKDIR/node_modules/retext-equality/lib/index.js:129:5)
    at visitor ($MYWORKDIR/node_modules/retext-equality/lib/index.js:88:23)
    at overload ($MYWORKDIR/node_modules/unist-util-visit/index.js:27:12)
    at one ($MYWORKDIR/node_modules/unist-util-visit-parents/index.js:34:25)
    at all ($MYWORKDIR/node_modules/unist-util-visit-parents/index.js:57:16)
    at one ($MYWORKDIR/node_modules/unist-util-visit-parents/index.js:42:28)
    at visitParents ($MYWORKDIR/node_modules/unist-util-visit-parents/index.js:26:3)
    at visit ($MYWORKDIR/node_modules/unist-util-visit/index.js:22:3)
    at transformer ($MYWORKDIR/node_modules/retext-equality/lib/index.js:70:5)

Does this library need a specific nodejs version or other libraries than

I don't have a lot of experience with JavaScript, so sorry if I made any beginner's mistake 😅

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.