Code Monkey home page Code Monkey logo

textlint-rule-use-si-units's Introduction

textlint-rule-use-si-units npm

Use SI Units

sample texts

  1. SI単位系の単位以外の使用を禁止します
  2. SI単位系の単位とは以下のいずれかの単位、またはそれらの組み合わせ(組立単位)を指します
    • SI基本単位(s, m, kg, A, K, mol, cd)
    • 固有の名称をもつSI組立単位(rad, sr, Hz, N, Pa, Jなど22種)
  3. 以下の文字は単体では単位となることができませんが、単位と組み合わせて使用できます
    • SI接頭語(M, G, k, mなど20種)
    • SI単位を組み合わせる際に使用される記号(, ^, -, ·, ・, ・, (, ))
    • 次元を表すための数字(e.g. m^2)
  4. 以下のSI併用単位も許容します
    • SIに属さないが、SIと併用される単位(min, h, d, au, °, ′, ″など16種)
    • これらはrestrictNonSIUnitsオプションで禁止できます

指摘の対象とする文字列

  • 数値 + 単位の組み合わせを検出します
    • e.g.「10 m」「273 K」「123 kgm^2/s^3」
    • 数値と単位の間には半角スペースが入っている必要があります
      • IDや型番のような、単位と関係ない文字列を誤検出するのを防ぐためです

指摘の対象としない文字列

  • 日本語の単位や助数詞
    • e.g.「枚」「本」「糎」「㌢㍍」
  • 小数点や記号入りの数値
    • e.g.「2.56 m/s」「1.1e-10 m」
    • ただし、小数点・記号より後にも数字があればその部分を検出します
  • LaTeX等で数値と単位の間に半角スペース以外を使用しているもの
    • e.g.「10\,m」「\SI{123}{kgm^2/s^3}」「$123\ \mathrm{kgm^2/s^3}$

Install

Install with npm:

npm install textlint-rule-use-si-units

Usage

Via .textlintrc(Recommended)

{
    "rules": {
        "use-si-units": true
    }
}

Via CLI

textlint --rule use-si-units README.md

Options

  • allowedUnits
    • この配列にある文字列には、SI単位系に従っていなくとも警告を出しません
  • restrictNonSIUnits
    • false (default): SI併用単位も使用できます
    • true: SI併用単位の使用を禁止し、SIに属する単位のみ認めます
{
    "rules": {
        "use-si-units": {
            "allowedUnits": [""],
            "restrictNonSIUnits": true
        }
    }
}

Build

Builds source codes for publish to the lib folder. You can write ES2015+ source codes in src/ folder.

npm run build

Tests

Run test code in test folder. Test textlint rule by textlint-tester.

npm test

License

ISC © kn1cht

textlint-rule-use-si-units's People

Contributors

dependabot[bot] avatar kn1cht avatar misogihagi avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

misogihagi

textlint-rule-use-si-units's Issues

「/」には、SI単位系で使用できない文字が含まれています

READMEやテストケースからは既知なのか判断できなかったので報告させていただきますが、「半角スペース」+「半角スラッシュ」の組み合わせがすべて表題のメッセージとともにエラーとなります。

image

なお、上の画像のようにLaTeXの数式モードなどでスペースが無視される場合は、単純にスペースを削除することがワークアラウンドとなります。

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.