mirror of
https://github.com/cheat/cheat.git
synced 2024-12-22 04:35:06 +01:00
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:
parent
7abb663bf4
commit
edd7b5e806
26
README.md
26
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:
|
||||
|
||||
<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
|
||||
|
@ -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']:
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user