diff --git a/README.md b/README.md index ec0ec10..7d8a5c6 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ variable set, you may edit cheatsheets with: cheat -e foo ``` -If the 'foo' cheatsheet already exists, it will be opened for editing. +If the `foo` cheatsheet already exists, it will be opened for editing. Otherwise, it will be created automatically. After you've customized your cheatsheets, I urge you to track `~/.cheat/` along @@ -109,13 +109,32 @@ export CHEATPATH="$CHEATPATH:/path/to/more/cheats" You may view which directories are on your `CHEATPATH` with `cheat -d`. ### Enabling Syntax Highlighting ### -`cheat` can apply syntax highlighting to your cheatsheets if so desired. To -enable this feature, set a `CHEATCOLORS` environment variable: +`cheat` can optionally apply syntax highlighting to your cheatsheets. To enable +syntax highlighting, export a `CHEATCOLORS` environment variable: ```sh export CHEATCOLORS=true ``` +#### Specifying a Syntax Highlighter #### +You may manually specify which syntax highlighter to use for each cheatsheet by +wrapping the sheet's contents in a [Github-Flavored Markdown code-fence][gfm]. + +Example: + +
+```sql
+-- to select a user by ID
+SELECT *
+FROM Users
+WHERE id = 100
+```
+
+ +If no syntax highlighter is specified, the `bash` highlighter will be used by +default. + + See Also: --------- - [Enabling Command-line Autocompletion][autocompletion] @@ -124,5 +143,6 @@ See Also: [autocompletion]: https://github.com/chrisallenlane/cheat/wiki/Enabling-Command-line-Autocompletion [dotfiles]: http://dotfiles.github.io/ +[gfm]: https://help.github.com/articles/creating-and-highlighting-code-blocks/ [installing]: https://github.com/chrisallenlane/cheat/wiki/Installing [related-projects]: https://github.com/chrisallenlane/cheat/wiki/Related-Projects diff --git a/bin/cheat b/bin/cheat index 2a66744..a14e3a9 100755 --- a/bin/cheat +++ b/bin/cheat @@ -42,7 +42,7 @@ from docopt import docopt if __name__ == '__main__': # parse the command-line options - options = docopt(__doc__, version='cheat 2.1.28') + options = docopt(__doc__, version='cheat 2.2.0') # list directories if options['--directories']: diff --git a/cheat/utils.py b/cheat/utils.py index 9b2af04..e8c850d 100644 --- a/cheat/utils.py +++ b/cheat/utils.py @@ -21,9 +21,9 @@ def colorize(sheet_content): return sheet_content first_line = sheet_content.splitlines()[0] - lexer = get_lexer_by_name('bash') + lexer = get_lexer_by_name('bash') if first_line.startswith('```'): - sheet_content = '\n'.join(sheet_content.split('\n')[1:]) + sheet_content = '\n'.join(sheet_content.split('\n')[1:-2]) try: lexer = get_lexer_by_name(first_line[3:]) except Exception: diff --git a/setup.py b/setup.py index 0107293..91512bc 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ import os setup( name = 'cheat', - version = '2.1.28', + version = '2.2.0', author = 'Chris Lane', author_email = 'chris@chris-allen-lane.com', license = 'GPL3',