UNPKG

@jti/antora-extension-repeated_words

Version:

An Antora extension that checks Asciidoc source files for repeated words in prose.

54 lines (43 loc) 1 kB
// Test the repeated words extension for Antora. 'use strict' const { check } = require('../index') const test = require('ava') test('repeated_words', t => { // t.plan(3) // no repeats t.deepEqual(check(`This is a test`), []) // repeated the t.deepEqual( check(`The the quick brown fox.`), [ { line: 1, offset: 1, repeated: 'the', source: 'The the quick brown fox.' }, ] ) // valid repeat t.deepEqual(check(`Swat the tse tse fly.`), []) // custom valid repeat t.deepEqual(check(`Eat the apple apple.`, { apple: true }), []) // multi-line repeat (second line must end with linebreak!) t.deepEqual( check(`This is an example of the\nthe multi-line check.\n`), [ { line: 2, offset: 0, repeated: 'the', source: 'the multi-line check.', }, ] ) // Empty content should not throw an error. t.deepEqual( check(), [] ) }) // vim: tw=0 ai et ts=2 sw=2