Minor revisions on #244

- When using GFM code fences, strip the last line in addition to the
  first
- Updated `README.md` to mention the new feature
- `minor` version-bump to `2.2.0`.
This commit is contained in:
Chris Lane 2017-02-28 18:59:27 -05:00
parent 7abb663bf4
commit edd7b5e806
4 changed files with 27 additions and 7 deletions

View File

@ -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:
<pre>
```sql
-- to select a user by ID
SELECT *
FROM Users
WHERE id = 100
```
</pre>
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

View File

@ -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']:

View File

@ -23,7 +23,7 @@ def colorize(sheet_content):
first_line = sheet_content.splitlines()[0]
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:

View File

@ -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',