We added Russian to RedPen, now it’s your turn…

RedPen proved to be an extremely flexible and universal tool. We managed to add basic Russian language support without any major changes done to the code. In fact, the only thing that we had to implement was Russian language auto-detection. The rest worked out the box with simple modification made to the default symbols configuration: in Russian language «quote» is used instead of “quote” and instead of #. Most likely, it will work equally fine for Ukrainian and Belorussian as well, and maybe some other languages using the Cyrillic script. This is how it looks like in RedPen Intellij Plugin:

russian

Actually adding custom languages to RedPen can be done in Intellij IDEA without making any modifications to RedPen itself. Use Settings -> Editor -> RedPen-> Import.

import-settings

For example, to add Russian language with correct double quotation marks, number sign and a couple of validators all you need to do is import a file with the following contents:

<redpen-conf lang="ru">
    <validators>
        <validator name="InvalidSymbol"/>
        <validator name="NumberFormat">
            <property name="decimal_delimiter_is_comma" value="false"/>
            <property name="ignore_years" value="true"/>
        </validator>
    </validators>
    <symbols>
        <symbol name="NUMBER_SIGN" value="№" invalid-chars="##" before-space="true"/>
        <symbol name="LEFT_DOUBLE_QUOTATION_MARK" value="«" invalid-chars="&quot;" before-space="true"/>
        <symbol name="RIGHT_DOUBLE_QUOTATION_MARK" value="»" invalid-chars="&quot;" after-space="true"/>
    </symbols>
</redpen-conf>

Only symbols that are different from English configuration should be listed. As for validators, you need to list all that you would like to use.

Most European/Western languages should also work fine with RedPen either using the default English configuration or a slight modification of it.

If you decide to add your own custom language, then it is a good idea to export English language configuration via Settings -> Editor -> RedPen-> Export and to change the language name in lang attribute of redpen-conf tag of the resulting file. It will serve as a good template to start with.

Then, optionally, you can add spelling and/or other dictionaries by specifying file names in either dict or list validator properties. Dictionary files are just text files with words listed one per line.

Advertisements
We added Russian to RedPen, now it’s your turn…

RedPen IntelliJ IDEA Plugin

To make usage of RedPen among developers even easier we created an Intellij IDEA Plugin that also works with recent releases of other JetBrains IDEs. This plugin integrates RedPen text validation by adding a new RedPen inspection.

editor

By default, RedPen validation errors are underlined with red (Intellij error style), but you can change it to yellow (warning) or any other highlighting style in Settings -> Editor -> Inspections -> Code style issues -> RedPen Validation.

Alternatively, raw validation error messages can be listed by pressing Ctrl+Alt+Shift+R or via IDEA menu Analyze -> RedPen: List Errors having a file selected either in editor or in the Project pane.

Installation

The plugin is available in JetBrains Plugin Repository and can be installed the same way as any other IDEA plugin.

Just open Settings -> Plugins -> Browse Repository, and search for RedPen to install.

File formats

RedPen plugin supports the following file formats provided that the relevant plugins are installed:

  • Plain Text
  • Properties and Resource Bundles
  • Markdown
  • AsciiDoc

Language support

The plugin supports all default RedPen languages and variants (currently, English and Japanese). Language and variant are auto-detected for each file, but can be manually overridden per file via status bar widget. Manually chosen language will be saved to .idea/redpen/files.xml and therefore selection will be preserved within the project.

status-widget

Quick fixes

Some validation errors can be fixed via quick fix (Alt+Enter when cursor is on an error). If no specific fix is available, it will at least offer you to remove the erroneous text. We will be adding more specific quick fixes in later releases.

quick-fix

RedPen configuration

RedPen is highly customizable with its configuration files, where you can define specific validators, change their properties or configure valid and invalid symbols for your writing style.

All the same can be done using RedPen configuration in Settings -> Editor -> RedPen.

Screenshot from 2016-03-10 13-17-45

Validators can be disabled by unchecking them and their properties can be edited by double-clicking on them in the table. Different properties are separated by semicolons, so you can use comma-separated values for e.g. list properties, allowing to use short custom dictionaries (see Advanced Topics for details). Spaces after = are not trimmed, which allows you to have space-only values for e.g. start_from property.

Screenshot from 2016-03-10 13-18-01

If you already have configuration files in xml format that you previously used with command-line version of RedPen, you can import them in the Settings dialog using the Import button. In a similar way Export button allows you to save current configuration snapshot for future use in other projects.

Configuration is edited or imported for each language and variant separately. If you have changed the default configuration for some language and variant pair, it will be stored per project under .idea/redpen directory, so it can be shared with fellow developers by committing it to version control.

Advanced topics

In case you want to edit raw xml configuration files under .idea/redpen, make sure you either reload the project or switch focus away from IDEA for the changes to take effect.

Many RedPen validators support custom dictionaries. In most cases, they provide two properties, list and dict.

You can use the list property to provide a short inline dictionary, just separate words with commas, e.g. list=apples,oranges. Do not put spaces between the words.

Longer custom dictionaries can be put into separate files under .idea/redpen directory. Once the file is there, you can use the dict property to specify its name, e.g. dict=mywords.txt

JavaScriptValidator is a special one, it allows you to write additional custom validators in JavaScript. By default, you can put such scripts to .idea/redpen/js directory or override the location using script_path property. All custom validators from *.js files will be activated if JavaScriptValidator is enabled in Settings.

 

RedPen IntelliJ IDEA Plugin

RedPen WordPress Plugin is now available

As a major step towards popularization of RedPen we created a WordPress Plugin. It was never easier to auto-detect mistakes in posts before they get published. RedPen Plugin allows validating posts as you type by marking validation errors in-place in Visual WordPress editor or highlighting them on-click in Text WordPress editor. Mistake explanation can be found by hovering marked text in the post or in a list below, which shows all currently present mistakes.

screenshot-1

To make it easier to maintain multilingual websites the language of the current post is detected automatically up to a variant (e.g. different Japanese symbol widths: zenkaku or hankaku). However, manual language change is also available if auto-detection fails (e.g. for cases when multiple languages are used in a single post).

Validation starts working out of the box after simple installation from WordPress Plugin Directory. Advanced users of RedPen will find it easy to customize RedPen settings to match their needs: all validators and symbols can be easily configured via convenient GUI. Don’t hesitate to modify the configuration, it can always be reset to default by a single click.

screenshot-2

The plugin is integrated with the RedPen Server via REST API. By default, the plugin uses public RedPen installation at Heroku for validation. However, if you are uncomfortable sending your text for validation to an external server, you can easily configure the plugin to use your own instance of RedPen Server. Server location is configurable via Settings > Writing.

screenshot-3

RedPen WordPress Plugin is now available