Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tpkn/has-cyr
Module that searches for cyrillic letters in the text
https://github.com/tpkn/has-cyr
Last synced: 6 days ago
JSON representation
Module that searches for cyrillic letters in the text
- Host: GitHub
- URL: https://github.com/tpkn/has-cyr
- Owner: tpkn
- License: mit
- Created: 2017-12-11T19:24:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-07-16T13:43:29.000Z (over 5 years ago)
- Last Synced: 2024-11-14T14:32:27.055Z (2 months ago)
- Language: JavaScript
- Size: 47.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Has Cyr [![npm Package](https://img.shields.io/npm/v/has-cyr.svg)](https://www.npmjs.org/package/has-cyr)
Module that searches for cyrillic characters in the text. It can highlight each cyrillic character or group of characters, or just transliterate them.
![preview](https://raw.githubusercontent.com/tpkn/has-cyr/master/preview.png)
## Installation
```bash
npm install has-cyr
```## API
### hasCyr(text[, preprocessor, translit])
### text
**Type**: _String_### preprocessor
**Type**: _Function_
Function helps modify matches### translit
**Type**: _Boolean_
**Default**: `false`
Auto transliteration of cyrillic characters## Usage
```javascript
const chalk = require('chalk');
const hasCyr = require('has-cyr');function chalkHighlighter(str){
return chalk.red.bold(str);
}let text = 'Lогем iрsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod темроr incididunt ut labоге et dolore magna aliqua. Ut хуй ad minim veniam, quis nostrud ехегсitation ullamco laboris nisi ut aliquip eх ea соммоdo сопsequat. Duis aute irure dolor в reprehenderit in voluptate velit esse cillum dоlоre eu fugiat nulla pariatur. Ехсерtеr sint occaecat cupidatat поп proident, sunt in сиlра qui officia deserunt mollit anim id est laborum.';
let cyr = hasCyr(text, chalkHighlighter);
if(cyr){
console.log(cyr);
}
```As an additional feature it can transliterate matches.
```javascript
let cyr = hasCyr(text, chalkHighlighter, true);
```![translit](https://raw.githubusercontent.com/tpkn/has-cyr/master/translit.png)
## Changelog
#### v1.0.4 (2018-11-20):
- now consecutive cyrillic characters would be grouped together