Skip to content

Commit

Permalink
Merge pull request #73 from bordaigorl/devel
Browse files Browse the repository at this point in the history
Changes for v2.6.0
  • Loading branch information
Emanuele D'Osualdo committed Feb 16, 2015
2 parents 5970d8c + 045e215 commit 0b24761
Show file tree
Hide file tree
Showing 10 changed files with 442 additions and 102 deletions.
3 changes: 3 additions & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[
{ "keys": [","], "command": "run_macro_file", "args":{"file": "Packages/Evernote/EvernoteAutoTags.sublime-macro"}, "context":
[
{ "key": "setting.evernote_autocomplete", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*tags\\s*:.*$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted", "match_all": true },
Expand All @@ -10,6 +11,7 @@
},
{ "keys": [" "], "command": "auto_complete", "context":
[
{ "key": "setting.evernote_autocomplete", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*tags\\s*:\\s*$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted", "match_all": true },
Expand All @@ -19,6 +21,7 @@
},
{ "keys": [","], "command": "run_macro_file", "args":{"file": "Packages/Evernote/EvernoteAutoTagsQuoted.sublime-macro"}, "context":
[
{ "key": "setting.evernote_autocomplete", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": "^\\s*tags\\s*:.*$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted", "match_all": true },
Expand Down
18 changes: 15 additions & 3 deletions Evernote.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
{
// inline_css is documented at https://github.com/bordaigorl/sublime-evernote/wiki/Styling
"inline_css": {
"pre": "color: #000000; font-family: monospace,monospace; font-size: 0.9em; white-space: pre-wrap; word-wrap: break-word; background-color: #f8f8f8; border: 1px solid #cccccc; border-radius: 3px; overflow: auto; padding: 6px 10px; margin-bottom: 10px;",
"pre": "color: #000000; font-family: monospace,monospace; font-size: 0.9em; white-space: pre-wrap; word-wrap: break-word; border: 1px solid #cccccc; border-radius: 3px; overflow: auto; padding: 6px 10px; margin-bottom: 10px;",
"code": "color: black; font-family: monospace,monospace; font-size: 0.9em;",
"inline-code": "color: #000000; font-family: monospace,monospace; padding: 0.1em 0.2em; margin: 0.1em; font-size: 85%; background-color: #F5F5F5; border-radius: 3px; border: 1px solid #cccccc;",
"h1": "margin-bottom: 1em; margin-top: 1.2em;",
"footnotes": "border-top: 1px solid #9AB39B; font-size: 80%;",
"hr": "color:#9AB39B;background-color:#9AB39B;height:1px;border:none;",
"sup": "color:#6D6D6D;font-size:1ex",
"blockquote": "border-left: .5ex solid #BFBFBF; margin-left: 0px; padding-left: 1em; margin-top: 1.4285em; margin-bottom: 1.4285em;",
// ONLY USED IF wiki_tables = true
// ONLY USED IF wiki_tables or gfm_tables are enabled
"table": "border-collapse: collapse; border-spacing: 0; margin: 1em;",
"td": "border: 1px solid #DDD; padding: 6px 13px;",
"th": "border: 1px solid #DDD; padding: 6px 13px;",
"tr:odd": "border: 1px solid #DDD; padding: 6px 13px;",
"tr:even": "border: 1px solid #DDD; padding: 6px 13px; background-color: #F8F8F8;"
},
"code_highlighting_style": "github",
"code_friendly": true,
"gfm_tables": true,
"wiki_tables": false,
"emphasis_mark": "_",
"strong_mark": "**",
"item_mark": "*",
"notes_order": "updated",
"max_notes": 100,
"update_on_save": false,
"evernote_autocomplete": true,
"sort_notebooks": false,
"show_stacks": true
"show_stacks": true,
"open_single_result": true,
"warn_on_close": true
}
101 changes: 70 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
Evernote for Sublime Text
=========================

[![release badge]][release]
[![licence badge]][licence]
[![stars badge]][repo]
[![issues badge]][issues]
[![tips badge]][gratipay]
[![paypal badge]][paypal]
[![chat badge]][gitter]

[Sublime Text](http://www.sublimetext.com/3) plugin for [Evernote](http://www.evernote.com).

This package is based on [SublimeEvernote](https://github.com/jamiesun/SublimeEvernote) for ST2 but is only supported on ST3 and adds many new features.

To start using it install it from Package Control and type "Evernote" on the Command Pallette (<kbd>ctrl+shift+p</kbd>). See [First Use](#first-use) for linking the plugin to your account.

If you like this plugin and would like to support its development please consider donating through a [paypal donation][paypal] or using [gratipay].

# Main Features

* **Send a note to Evernote:** converts the markdown document in the current view into rich text and sends it to your Evernote. You will be able to choose a title, tags and the notebook where to store it.
Expand All @@ -21,43 +31,46 @@ See [Commands](#commands) and the [wiki] for details.

## What's new

**v2.6.0**

+ Asynchronous operations: save/update/load from server does not block the UI
+ Warn on close if modified but not uploaded (`warn_on_close` setting)
+ Added support for GFM tables syntax (#51, #58)
+ Added support for strikethrough (#38)
+ Added support for underline (see [special syntax][wiki-md])
+ Settings for default emphasis/unordered list marks
+ Better support for Unicode (#52)
+ CSS styling for inline code fixed (#53)
+ Support for HTTPS for Package Control v3 users ([see wiki][wiki])
+ If search has one result open it directly (#65)
+ Added `evernote_has_guid` context key
+ Search command now supports snippets for prompt (#54)

**v2.5.4**

+ Bugfix: solves a problem in setting a new token (see #48)
+ Added a `debug` flag in settings

**v2.5.3**

+ Added links to notes management (thanks to @rahul-ramadas, see #36)
+ Open note in Client command, tested on Windows only (thanks to @rahul-ramadas)
+ Bugfixes: better error messages, correct handling of unnamed attachments
For earlier versions see the [wiki](https://github.com/bordaigorl/sublime-evernote/wiki/Changelog).

**v2.5.2**

+ Added attachments management: list, open, insert attachments from file or url (solves #24)
+ Notebook list can show stack names and be sorted (#30, thanks @danielfrg)
+ Added `wiki_tables` setting to enable Wiki-style tables syntax (solves #18)
+ Now notes in webapp are opened in default browser (solves #22)
+ Configuration asks for noteStoreUrl so the plugin works properly for yinxiang.com (solves #20)

**v2.5.1**
# Installation

+ Bugfix: metadata autocomplete now loads settings correctly
The Evernote plugin can be installed using Package Control.
See the [wiki] for detailed instructions.

**v2.5.0**
# Issues

+ [Search note](#search-note) command added
+ [Attach](#attach-to-note) command added
+ [Clip](#clip-to-note) command added
+ [View in WebApp](#view-note-in-webapp) command added
+ Autocomplete in metadata block
+ Unicode chars in tags properly displayed
+ Creation and update dates are displayed in status
You may encounter problems in using the plugin.
Issues can be posted at the [github repository][issues].

# Installation
Before posting a new issue:

The Evernote plugin can be installed using Package Control.
See the [wiki] for detailed instructions.
1. Enable the `debug` setting in your `Evernote.sublime-settings` file and try again.
If the problem persists take a note of the output in the console.
Make sure you delete personal information (e.g. Developer Token) from the output before posting it in an issue.
2. Check the [wiki]
3. Search for similar issues [here](https://github.com/bordaigorl/sublime-evernote/issues?q=is%3Aissue)

# Usage

Expand Down Expand Up @@ -90,8 +103,8 @@ The plugin does not install keymaps, if you wish you may add a variation of the
you can also overwrite the standard "save" bindings for Evernote notes as follows:

```
{ "keys": ["ctrl+s"], "command": "save_evernote_note", "context": [{"key": "evernote_note"}] },
{ "keys": ["ctrl+s"], "command": "send_to_evernote", "context": [{"key": "evernote_note", "operator": "equal", "operand": false}, {"key": "selector", "operator": "equal", "operand": "text.html.markdown.evernote"}] },
{ "keys": ["ctrl+s"], "command": "save_evernote_note", "context": [{"key": "evernote_note"}, {"key": "evernote_has_guid"}] },
{ "keys": ["ctrl+s"], "command": "send_to_evernote", "context": [{"key": "evernote_note"}, {"key": "evernote_has_guid", "operator": "equal", "operand": false}] },
```

you would still be able to save the note as a file by using the `File > Save` menu.
Expand Down Expand Up @@ -184,7 +197,7 @@ This command will open the currently opened note in your local Evernote client,

You can use Markdown to write notes but there are some limitations due to Evernote's formats. For example, `class` and `id` are forbidden attributes in Evernote notes so the Markdown converter has been modified to never output them and raw HTML cannot contain them. If you write illegal content the plugin will display a dialog showing the reason why Evernote is complaining.

Please see the [wiki documentation](https://github.com/bordaigorl/sublime-evernote/wiki/Supported-Markdown) for more details.
Please see the [wiki documentation][wiki-md] for more details.

## Metadata

Expand Down Expand Up @@ -221,23 +234,30 @@ The following settings can be customised:
Setting | Purpose
--------------------------|------------------------
`md_syntax` | a string pointing to a `tmLanguage` file which you want to associate with notes opened from Evernote.
`inline_css` | a dictionary associating some HTML element names to inline CSS styles; currently the only elements that can be styled in this way are: `pre`, `code`, `h1`, `hr`, `blockquote` and `sup`. Additionally `footnotes` can be associated to some style for the `div` containing the footnotes at the end of the note. The markdown of a note can contain (almost) arbitrary HTML blocks *but* Evernote only accepts a subset of the elements and attributes (`class` and `id` are disallowed). See [here](http://dev.evernote.com/doc/articles/enml.php) for details.
`inline_css` | a dictionary associating some HTML element names to inline CSS styles; this setting is documented in the [wiki](https://github.com/bordaigorl/sublime-evernote/wiki/Styling). The markdown of a note can contain (almost) arbitrary HTML blocks *but* Evernote only accepts a subset of the elements and attributes (`class` and `id` are disallowed). See [here](http://dev.evernote.com/doc/articles/enml.php) for details.
`code_highlighting_style` | a pygments style among `autumn`, `default`, `github`, `monokai`, `perldoc`, `vim`, `borland`, `emacs`, `igor`, `murphy`, `rrt`, `vs`, `bw`, `friendly`, `native`, `tango`, `xcode`, `colorful`, `fruity`, `manni`, `pastie`, `trac`.
`code_friendly` | if `true` the `code-friendly` extra of markdown2 is enabled
`evernote_autocomplete` | when this setting is true, suggestions will be offered for autocompletion of the `notebook` and `tags` fields in metadata. Default is true.
`emphasis_mark` | when converting from HTML to markdown, use this as emphasis markup. Valid values are `"*"` or `"_"` (default). It is set to `"*"` when `code_friendly` is true.
`strong_mark` | when converting from HTML to markdown, use this as emphasis markup. Valid values are `"__"` or `"**"` (default)
`item_mark` | when converting from HTML to markdown, use this as unordered list item markup. Valid values are `"+"`, `"-"` or `"*"` (default)
`notes_order` | how to sort the notes in the panels; possible values: `created`, `updated`, `relevance`, `update_sequence_number`, `title`. Set the `notes_order_ascending` setting to `true` to reverse the selected order.
`max_notes` | maximum number of notes in a panel; default is 100.
`update_on_save` | when this setting is true, saving a file containing a note will also update (overwriting it) the online version. Default is false.
`sort_notebooks` | sorts notebooks alphabetically in pallette
`show_stacks` | shows the stack of notebooks in pallette
`open_single_result` | when a search returns only one note open it directly skipping the results pallette (defaults to `true`)
`warn_on_close` | when closing a modified note without saving to Evernote, offer a choice to save or discard changes (defaults to `true`)
`gfm_tables` | enable GFM table syntax (default `true`)
`wiki_tables` | enable Wiki table syntax (default `false`)
`debug` | enables logging in the console


# Acknowledgements

The current maintainer is [bordaigorl].

If you like this plugin and would like to support its development please consider donating through a [paypal donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JFWLSUZYXUHAQ) or using [gittip](https://www.gittip.com/bordaigorl/).
If you like this plugin and would like to support its development please consider donating through a [paypal donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JFWLSUZYXUHAQ) or using [gratipay].

If you would like to contribute, please see [CONTRIBUTING].

Expand All @@ -261,6 +281,8 @@ The plugin has been made possible by the contribution of several people:

If you think your name should be here, let us know!

Also thanks to our first donor, Matthew Baltrusitis!

Libraries (some adapted to work with Evernote formats):

* Markdown2 converter: [trentm](https://github.com/trentm/python-markdown2/)
Expand All @@ -270,4 +292,21 @@ Libraries (some adapted to work with Evernote formats):

[CONTRIBUTING]: <CONTRIBUTING.md>
[wiki]: <https://github.com/bordaigorl/sublime-evernote/wiki/>
[bordaigorl]: <https://github.com/bordaigorl>
[wiki-md]: <https://github.com/bordaigorl/sublime-evernote/wiki/Supported-Markdown>
[bordaigorl]: <https://github.com/bordaigorl>
[gratipay]: <https://gratipay.com/bordaigorl/>
[paypal]: <https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=JFWLSUZYXUHAQ>
[gitter]: <https://gitter.im/bordaigorl/sublime-evernote>
[release]: <https://github.com/bordaigorl/sublime-evernote/releases>
[licence]: <https://raw.githubusercontent.com/bordaigorl/sublime-evernote/master/LICENSE>
[issues]: <https://github.com/bordaigorl/sublime-evernote/issues>
[repo]: <https://github.com/bordaigorl/sublime-evernote/>

[release badge]: https://img.shields.io/github/release/bordaigorl/sublime-evernote.svg
[licence badge]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[stars badge]: https://img.shields.io/github/stars/bordaigorl/sublime-evernote.svg
[issues badge]: https://img.shields.io/github/issues/bordaigorl/sublime-evernote.svg
[tips badge]: https://img.shields.io/gratipay/bordaigorl.svg
[chat badge]: https://img.shields.io/badge/gitter-join%20chat-green.svg
[paypal badge]: https://img.shields.io/badge/paypal-donate-blue.svg

18 changes: 18 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Release Checklist

* update `EVERNOTE_PLUGIN_VERSION`
* check `DEBUG` is `False`
* update Changelog in Readme
* add update message to `messages` and `messages.json`
* update Contributors in Readme if needed
* update wiki if needed
* add release on GitHub with release notes from Readme

# Documentation

* Known bugs in wiki:
- paragraphs and spacing #71, #67
- proxy
* More notes on issues in Readme
* See [issues with `needs-docs` label](https://github.com/bordaigorl/sublime-evernote/labels/needs-docs)

# Under consideration

Define a unified restricted format for metadata:
Expand Down
49 changes: 41 additions & 8 deletions lib/html2text.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def has_key(x, y):
xrange = range

# Use Unicode characters instead of their ascii psuedo-replacements
UNICODE_SNOB = 0
UNICODE_SNOB = 1

# Escape all special characters. Output is less readable, but avoids corner case formatting issues.
ESCAPE_SNOB = 0
Expand All @@ -65,6 +65,10 @@ def has_key(x, y):
IGNORE_IMAGES = False
IGNORE_EMPHASIS = False

UL_ITEM_MARK = '*'
EMPHASIS_MARK = '_'
STRONG_MARK = '**'

### Entity Nonsense ###

def name2cp(k):
Expand Down Expand Up @@ -207,9 +211,9 @@ def __init__(self, out=None, baseurl=''):
self.ignore_images = IGNORE_IMAGES
self.ignore_emphasis = IGNORE_EMPHASIS
self.google_doc = False
self.ul_item_mark = '*'
self.emphasis_mark = '_'
self.strong_mark = '**'
self.ul_item_mark = UL_ITEM_MARK
self.emphasis_mark = EMPHASIS_MARK
self.strong_mark = STRONG_MARK

if out is None:
self.out = self.outtextf
Expand Down Expand Up @@ -254,6 +258,7 @@ def __init__(self, out=None, baseurl=''):
self.abbr_data = None # last inner HTML (for abbr being defined)
self.abbr_list = {} # stack of abbreviations to write later
self.baseurl = baseurl
self.span_stack = []

try: del unifiable_n[name2cp('nbsp')]
except KeyError: pass
Expand Down Expand Up @@ -281,7 +286,7 @@ def close(self):

self.outtext = self.outtext.join(self.outtextlist)
if self.unicode_snob:
nbsp = unichr(name2cp('nbsp'))
nbsp = chr(name2cp('nbsp'))
else:
nbsp = u' '
self.outtext = self.outtext.replace(u'&nbsp_place_holder;', nbsp)
Expand Down Expand Up @@ -498,12 +503,40 @@ def handle_tag(self, tag, attrs, start):

if tag in ['em', 'i', 'u'] and not self.ignore_emphasis: self.o(self.emphasis_mark)
if tag in ['strong', 'b'] and not self.ignore_emphasis: self.o(self.strong_mark)
if tag in ['del', 'strike', 's', 'kbd']:

if tag == 'kbd':
if start:
self.o("<"+tag+">")
else:
self.o("</"+tag+">")

if tag in ['del', 'strike', 's']:
self.o("~~")

if tag in ['ins', 'u']:
self.o("==")

# evernote strikethrough and underlined
if tag == "span":
if start:
style = attrs.get('style')
if style == "text-decoration: line-through;":
self.span_stack.append("strike")
self.o("~~")
elif style == "text-decoration: underline;":
self.span_stack.append("underline")
# self.o('<span style="text-decoration: underline;">')
self.o('==')
else:
self.span_stack.append(False)
else:
style = self.span_stack.pop()
if style == "strike":
self.o("~~")
elif style == "underline":
# self.o('</span>')
self.o('==')

if self.google_doc:
if not self.inheader:
# handle some font attributes, but leave headers clean
Expand Down Expand Up @@ -801,7 +834,7 @@ def charref(self, name):
return unifiable_n[c]
else:
try:
return unichr(c)
return chr(c)
except NameError: #Python3
return chr(c)

Expand All @@ -813,7 +846,7 @@ def entityref(self, c):
except KeyError: return "&" + c + ';'
else:
try:
return unichr(name2cp(c))
return chr(name2cp(c))
except NameError: #Python3
return chr(name2cp(c))

Expand Down
Loading

0 comments on commit 0b24761

Please sign in to comment.