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

Improve language file documentation #432

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion langs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,16 @@ These are known, recognised and highlighted by Crayon. You can defined others, b

### Regex

* Written as per normal, without delimiters or escaping
* Written as per normal (using PHP's Perl-compatible regex or PCRE), without delimiters or escaping with the exception of `(`, which must be escaped in character classes
* Applied in the order they appear in the file. If language has reserved keywords, these should be higher than variables
* Whitespace around regex is ignored - only first character to last forms regex
* If single space is intended, use \s to avoid conflict with whitespace used for separation e.g. `TEST [t] \s\s\shello`
* Unescaped `(` not followed by `?` will be automatically replaced by `(?:`

### Regex modes

* Modes CASE_INSENSITIVE, MULTI_LINE and SINGLE_LINE correspond to PCRE's `i`, `m` and `s` modifiers respectively and are all set by default
* A mode can be unset (`OFF`, `NO` or `0`) with a single line such as `CASE_INSENSITIVE =OFF` (at least one space is required between the mode name and the `=`)

### Comments

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ You can even mix code together like on a real HTML page, by having `<script>`, `

Language information is found here in the Wordpress Admin: *Settings > Crayon > Languages > Show Languages* You can customise and create new languages and define how to capture each element (keywords, comments, strings, etc.) with regular expressions. Languages are structured `langs/lang-name/lang-name.txt`. Take a look at `langs/default/default.txt` and check out the neat regex of the default/generic language. See the [readme](langs/readme.md) in `langs/readme.md` for more information about the language file syntax.

You can add custom languages in `wp-content/uploads/crayon-syntax-highlighter/languages` with the same format as those in the plugin directory and they will remain after plugin updates.
You can add custom languages in `wp-content/uploads/crayon-syntax-highlighter/langs` with the same format as those in the plugin directory and they will remain after plugin updates. Custom languages with the same names as those in the plugin directory take precedence.

## Themes

Expand Down