Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite idnits as a JS library + CLI #24

Open
Tracked by #15
NGPixel opened this issue Jan 19, 2023 · 0 comments
Open
Tracked by #15

Rewrite idnits as a JS library + CLI #24

NGPixel opened this issue Jan 19, 2023 · 0 comments
Assignees

Comments

@NGPixel
Copy link
Member

NGPixel commented Jan 19, 2023

This proposal is for a rewrite of idnits in javascript, so that it can run both natively in the browser and on the server / console.

General Implementation

  • Implemented as a ESM library, exposing a single async function checkNits(opts), that resolves to a result object.
  • A separate cli.js parses command line arguments, calls the library and output the results in a console friendly format.
  • Section texts should be stored in a separate .json file.

Distribution

As a NPM package that can be both embedded into a web application or used as a standard CLI, on any platform supported by Node.js.

Arguments

Outdated
CLI mode Library mode Description
--version N/A Print the version and exit
--help N/A Print the help text and exit
--nowarn nowarn: false Don't issue warnings, only ID-Checklist violations
--verbose N/A Show more information about offending lines
--nitcount N/A Show a count of nits
--debug N/A Debug output, especially of boilerplate matching
--year year: 2023 Expect the given year in the boilerplate
--checklistwarn N/A Only warn (no errors) for ID-Checklist violations
--nonascii noascii: false Disable warnings for non-ascii characters
--submitcheck submitcheck: false Only output errors and warnings related to 1id-guidelines
--status doctype status: 'doctype' Assume the given intended document type

See README.md instead.

Returns

{
  result: string, // either "success" or "failed"
  file: {
    path: string, // Path of the document
    lines: Number, // Number of total lines processed
    size: Number // filesize in bytes
  },
  issues: [
    {
      lines: Array<Number>, // start and end line number (starts at 1), e.g. [1,5]
      message: string, // error message
      ref: string, // optional link reference
      level: string // either "warn" or "error"
    },
    ...
  ]
}

Web UI Mockup

The library could be integrated into a web app, allowing the user to browse for a document to validate. The document would be presented in a code editor like view, with warnings / errors shown on relevant lines (either inline or on the side).

ui-mockup

Breakdown of the Current Implementation

  1. starts at L3053
  2. calls check_line()
    1. check line length
    2. check line spacing
    3. check line ending with hyphenated word
    4. check ascii chars only and not ctrl chars
    5. check that abstract and "status of memo" are not numbered
    6. check RFC 2119 language
    7. check example domain names
    8. check ipv4 addresses
  3. calculate page count
  4. warn if draft starts with PK or BM
  5. normalize text and try a list of matches
    1. calls match_para()
  6. calls report()
    1. todo

Original idnits SOW

idnits-SOW-00.pdf

@NGPixel NGPixel added this to Roadmap Feb 22, 2023
@github-project-automation github-project-automation bot moved this to To Do in Roadmap Feb 22, 2023
@NGPixel NGPixel changed the title JS rewrite proposal (WIP) Rewrite idnits as JS library + CLI Feb 22, 2023
@NGPixel NGPixel changed the title Rewrite idnits as JS library + CLI Rewrite idnits as a JS library + CLI Feb 22, 2023
@NGPixel NGPixel self-assigned this Feb 22, 2023
@rjsparks rjsparks removed the status in Roadmap Feb 28, 2023
@rjsparks rjsparks removed this from Roadmap Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@NGPixel and others