Filter functions

This is the documentation for 3.0.2 version, which is not the latest version. Consider upgrading to 4.3.0.

Filtering is used to clean the text after generation, adding caps and removing extra punctuation. It is regexp based and will have as an input a string, previously generated by Pug.

The filtering mechanism is called automatically.

Protect sections from being filtered

Filtering is nice because it will automatically manage capitalization etc. for you. But sometimes you want to disable this mechanim for some sections: Baba Inc. is a nice company instead of Baba Inc. Is a nice company.

Use the protectString(string) js function to protect your strings from begin filtered:

will output protected.string (and not protected. String).

You should favor the protect tag which better cares for spacing.

Use the protect tag to protect structures:

will output the same.

Protected sections and contractions

Sections protected from filtering with protect will not be filtered. Different rules apply to what is before the protected section, namely articles, depending on the language.

In French, articles are not contracted when placed before a protected section:

| le
  protect
    OnePlus

will output le OnePlus (and not l’OnePlus).

In English, a/an mechanim does apply before protected sections:

| a
  protect
    AI company

will output an AI company (and not a AI company).

Special characters

§ and ¤ are special characters and must just not be used in your texts:

  • § is used to mark protected sections (§…​§ marks a section) before filtering.

  • ¤ is a space automatically inserted by RosaeNLG. The filtering mechanism needs to distinguish which spaces are natural from the automatic ones, especially in the protected sections.

Horizontal ellipsis ( and …​)

Three dots (…​) are automatically transformed into . You can also put directly in your mixins.

Capitalization is not automatic after because it is not systematic:

The first word after an ellipsis is capitalized if it begins a new grammatical sentence.

— Chicago Manual of Style 13.51