Skip to content

Commit

Permalink
Merge pull request #49 from facelessuser/feature/sublime-color-scheme
Browse files Browse the repository at this point in the history
Feature/sublime color scheme
  • Loading branch information
facelessuser authored Oct 21, 2017
2 parents 8f028f4 + 787ba5d commit 3379657
Show file tree
Hide file tree
Showing 15 changed files with 464 additions and 274 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
- pip install pep8-naming
- pip install pytest
- pip install mkdocs
- pip install mkdocs-material
- pip install "mkdocs-material<1.12.0"
- pip install pymdown-extensions
- pip install pygments
- npm install -g jshint
Expand All @@ -21,7 +21,7 @@ script:
- flake8 .
- jshint .
- python tests/spellcheck.py
- mkdocs build --clean --verbose --strict
- mkdocs build --clean
deploy:
- provider: pages
github_token: $GITHUB_TOKEN
Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# ExportHtml 2.7.0

Oct 20, 2017

- **NEW**: Add support for `.sublime-color-scheme` files.
- **NEW**: Drop option to include scheme in output.

# ExportHtml 2.6.0

Oct 6, 2017
Expand Down
4 changes: 3 additions & 1 deletion ExportBbcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def setup_print_block(self, curr_sel, multi=False):

if (
self.ignore_selections or
curr_sel is None or
(
not multi and
(curr_sel.empty() or curr_sel.size() <= self.char_limit)
Expand Down Expand Up @@ -314,7 +315,8 @@ def write_body(self, bbcode):
bbcode.write("\n" + (BBCODE_CODE % {"color": self.fground, "content": "..."}) + "\n\n")

else:
self.setup_print_block(self.view.sel()[0])
sels = self.view.sel()
self.setup_print_block(sels[0] if len(sels) else None)
self.convert_view_to_bbcode(bbcode)

bbcode.write(POST_END)
Expand Down
50 changes: 6 additions & 44 deletions ExportHtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import tempfile
import time
import re
import json
from .HtmlAnnotations import get_annotations
from .lib.browser import open_in_browser
from .lib.color_scheme_matcher import ColorSchemeMatcher
Expand Down Expand Up @@ -110,19 +109,6 @@
' />'
)

TOOL_DUMP_THEME = (
'<img onclick="dump_theme();" alt="" title="Download" '
'src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB'
'AAAAAQCAYAAAAf8/9hAAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXM'
'AAAsTAAALEwEAmpwYAAAAB3RJTUUH3AofFhAWTV9RXgAAAAxpVFh0'
'Q29tbWVudAAAAAAAvK6ymQAAAJtJREFUOMvdk9ENwyAQQ5+rDBA6Q'
'ZbI/gN0h3YE2gXi/lykhABN1b9aQkh3+CEwiEK2BYyAyhbwlORtce'
'CoEbgBqahnYI65C1CYr43eThd+1B8Ahkp0qXZZa8/2LlIFIG2i676'
'DmDMwS8pDcZzW7tt4DbwOr8/2ZPthe3FbS6yZ4thfQdrmE5DP5g7k'
'vLkCucdomtWDRJzUvvGqN6JK1cOooSjlAAAAAElFTkSuQmCC"'
' />'
)

TOOL_WRAPPING = (
'<img onclick="toggle_wrapping();" alt="" title="Toggle Wrapping" '
'src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAA'
Expand Down Expand Up @@ -219,20 +205,6 @@

BODY_END = '</pre>%(toolbar)s\n%(js)s\n</body>\n</html>\n'

INCLUDE_THEME = '''
<script type="text/javascript">
%(jshelper)s
</script>
<script type="text/javascript">
%(jscode)s
plist.color_scheme = %(theme)s;
function dump_theme() {
extract_theme('%(name)s');
}
</script>
'''

TOGGLE_LINE_OPTIONS = '''
<script type="text/javascript">
%(jscode)s
Expand Down Expand Up @@ -489,7 +461,6 @@ def get_tools(self, tools, use_annotation, use_wrapping):
"print": TOOL_PRINT,
"plain_text": TOOL_PLAIN_TEXT,
"annotation": TOOL_ANNOTATION if use_annotation else "",
"theme": TOOL_DUMP_THEME,
"wrapping": TOOL_WRAPPING if use_wrapping else ""
}
t_opt = ""
Expand All @@ -507,6 +478,7 @@ def setup_print_block(self, curr_sel, multi=False):

if (
self.ignore_selections or
curr_sel is None or
(
not multi and
(
Expand Down Expand Up @@ -574,20 +546,9 @@ def write_header(self, html):
)
}

if 'theme' in self.toolbar:
header_vars['js'] = INCLUDE_THEME % {
"jshelper": getjs('jshelper.js'),
"jscode": getjs('plist.js'),
"theme": json.dumps(
self.csm.get_plist_file(),
sort_keys=True, indent=4, separators=(',', ': ')
).encode('raw_unicode_escape').decode("utf-8"),
"name": self.csm.get_scheme_file(),
}
else:
header_vars['js'] = HTML_JS_WRAP % {
"jscode": getjs('jshelper.js')
}
header_vars['js'] = HTML_JS_WRAP % {
"jscode": getjs('jshelper.js')
}

header = HTML_HEADER % header_vars
html.write(header)
Expand Down Expand Up @@ -881,7 +842,8 @@ def write_body(self, html):
html.write(ROW_START)
html.write(TABLE_START)
else:
self.setup_print_block(self.view.sel()[0])
sels = self.view.sel()
self.setup_print_block(sels[0] if len(sels) else None)
processed_rows += "[" + str(self.curr_row) + ","
self.convert_view_to_html(html)
processed_rows += str(self.curr_row) + "],"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/markdown/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Parameter | Type | Description
`show_full_path` | boolean | Show full path for file name when displaying header. Default is `true`.
`save_location` | string | Path to save HTML file. If the file is wanted in the same file as the original, use ".". Otherwise, use the absolute path to where the file is desired. If there is an issue determining where to save the file, or the path does not exist, the OS temp folder will be used. Default is `None` (use temp folder).
`time_stamp` | string | Configure the time stamp of saved HTML when using `save_location`. To remove time stamps, just set to an empty string `""`. Please see Python's documentation on `time.strftime` for detailed info on formatting syntax. Default is `"_%m%d%y%H%M%S"`.
`toolbar` | array\ of\ strings | Option to display a toolbar with to access features in a generated HTML. This setting is an array of keywords that represent the icons in the toolbar to show. Valid keywords include `gutter`, `print`, `plain_text`, `annotation`, `theme`, and `wrapping`. Toolbar will appear when you mouse over the upper right corner of the window of the generated HTML. Default enables all.
`toolbar` | array\ of\ strings | Option to display a toolbar with to access features in a generated HTML. This setting is an array of keywords that represent the icons in the toolbar to show. Valid keywords include `gutter`, `print`, `plain_text`, `annotation`, and `wrapping`. Toolbar will appear when you mouse over the upper right corner of the window of the generated HTML. Default enables all.
`filter` | string | Filters to use on the theme's colors. The string is a sequence of filters separated by `;`. The accepted filters are `grayscale`, `invert`, `sepia`, `brightness`, `contrast`, `glow`, `saturation`, `hue`, and `colorize`. `brightness`, `saturation`, and `contrast` require a float parameter to specify to what magnitude the filter should be applied at. `glow` requires a float for intensity (usually something like .1 or .2 is sufficient). `hue` and `colorize` take a float that represents a degree. `hue` shifts the hue via the degree given (can accept negative degrees); hues will wrap if they extend past 0 degrees or 360 degrees. Example: `"filter": "sepia;invert;brightness(1.1);saturation(1.3);"`. Default is `""`.
`disable_nbsp` | boolean | Disable the translation of spaces into `&nbsp;`. This was originally introduced so I could copy and paste content into Microsoft Outlook. If this is not desired, you can disable it here.

Expand Down
126 changes: 0 additions & 126 deletions js/plist.js

This file was deleted.

Loading

0 comments on commit 3379657

Please sign in to comment.