From 7409f375b6c3ffa5b6bc141f47562005623e1308 Mon Sep 17 00:00:00 2001 From: George Oyang Date: Thu, 31 May 2012 11:09:43 +0800 Subject: [PATCH 1/5] Update clearly-highlight.js --- clearly-highlight.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/clearly-highlight.js b/clearly-highlight.js index aad3022..069be2f 100644 --- a/clearly-highlight.js +++ b/clearly-highlight.js @@ -9,8 +9,19 @@ function loadjs(callback) { loadjs(function() { $('#readable_iframe').contents().find('head').append(''); $.getScript('http://yandex.st/highlightjs/6.1/highlight.min.js', function(){ + $('#readable_iframe').contents().find('pre').each(function() { - $(this).replaceWith(function() { + var $this = $(this); + var ol = $this.find('code ol') + if(ol){ + ol.find('li').each(function(){ + $(this).replaceWith(function() { + var hl = hljs.highlightAuto($(this).text()); + return '
  • ' + hl.value + '
  • '; + }); + }); + }else + $(this).replaceWith(function() { var hl = hljs.highlightAuto($(this).text()); return '
    ' + hl.value + '
    '; }); From 907856d931eb7b72e7284fde90ad588409d236b5 Mon Sep 17 00:00:00 2001 From: George Oyang Date: Thu, 31 May 2012 13:22:34 +0800 Subject: [PATCH 2/5] Update readme.markdown --- readme.markdown | 48 +++--------------------------------------------- 1 file changed, 3 insertions(+), 45 deletions(-) diff --git a/readme.markdown b/readme.markdown index 0805a56..a4584ce 100644 --- a/readme.markdown +++ b/readme.markdown @@ -1,48 +1,6 @@ # Clearly Code -This bookmarklet uses [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) to highlight code blocks while using [Evernote](http://evernote.com/) [Clearly](http://www.evernote.com/clearly/). - - -## Before - -![](https://raw.github.com/kylewest/clearly-code/master/assets/clearly-code-before.png) - - -## After - -![](https://raw.github.com/kylewest/clearly-code/master/assets/clearly-code-after.png) - - -## Install - -[Click here](http://kylewest.github.com/clearly-code/) then drag the `Clearly Code` button to your your bookmarks bar. - - -## Usage - -1. Find something [interesting to read](http://railscasts.com/episodes/306-elasticsearch-part-1?view=asciicast). -2. Launch Evernote Clearly. -3. Click your `Clearly Code` bookmarklet. - - -### Saving to Evernote - -The clipper bundled with Clearly strips all formatting when saving to Evernote. If you'd prefer to save with formatting use the [regular Evernote clipper](http://www.evernote.com/evernote/). - - -## Testing - -Clearly code has been tested with Google Chrome 16 and Clearly v3.3324.156.156. - - -## License - -The MIT License (MIT) -Copyright (c) 2012 Kyle West - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +This bookmarklet uses [highlight.js](http://softwaremaniacs.org/soft/highlight/en/) to highlight code blocks while using [Evernote](http://evernote.com/) [Clearly](http://www.evernote.com/clearly/) +add some code to highlight code already formate like in here +wraped in list. \ No newline at end of file From c9ebea99705267bd9e0add2bf754b063a4483221 Mon Sep 17 00:00:00 2001 From: George Oyang Date: Thu, 31 May 2012 13:25:31 +0800 Subject: [PATCH 3/5] Update clearly-highlight.js --- clearly-highlight.js | 72 ++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 23 deletions(-) diff --git a/clearly-highlight.js b/clearly-highlight.js index 069be2f..466f923 100644 --- a/clearly-highlight.js +++ b/clearly-highlight.js @@ -1,30 +1,56 @@ function loadjs(callback) { - var fileref = document.createElement('script'); - fileref.setAttribute('type', 'text/javascript'); - fileref.onload = callback; - fileref.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); - if (typeof fileref !== 'undefined') { document.getElementsByTagName('head')[0].appendChild(fileref); } + var fileref = document.createElement('script'); + fileref.setAttribute('type', 'text/javascript'); + fileref.onload = callback; + fileref.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); + if (typeof fileref !== 'undefined') { document.getElementsByTagName('head')[0].appendChild(fileref); } } loadjs(function() { - $('#readable_iframe').contents().find('head').append(''); - $.getScript('http://yandex.st/highlightjs/6.1/highlight.min.js', function(){ - - $('#readable_iframe').contents().find('pre').each(function() { - var $this = $(this); - var ol = $this.find('code ol') - if(ol){ - ol.find('li').each(function(){ - $(this).replaceWith(function() { - var hl = hljs.highlightAuto($(this).text()); - return '
  • ' + hl.value + '
  • '; - }); + $('#readable_iframe').contents().find('head').append(''); + $.getScript('http://yandex.st/highlightjs/6.1/highlight.min.js', function(){ + + $('#readable_iframe').contents().find('pre').each(function() { + var $this = $(this); + var children = $this.children(); + console.log(children); + if(children.length>0){ + + var formated = false; + children.find('li').each(function(){ + formated=true; + $(this).replaceWith(function() { + var hl = hljs.highlightAuto($(this).text()); + return '
  • ' + hl.value + '
  • '; + }); + }); + if(!formated){ + $this.find('code').each(function(){ + formated=true; + $(this).replaceWith(function() { + var hl = hljs.highlightAuto($(this).text()); + return '' + hl.value + ''; + }); + }); + } + if(!formated){ + console.log('formating children'); + children.each(function(){ + formated=true; + $(this).replaceWith(function() { + var hl = hljs.highlightAuto($(this).text()); + return '
  • ' + hl.value + '
  • '; + }); + }); + $this.wrap('
      '); + }else console.log('formating ol li'); + }else{ + console.log('formating not formated code'); + $(this).replaceWith(function() { + var hl = hljs.highlightAuto($(this).text()); + return '
      ' + hl.value + '
      '; + }); + } }); - }else - $(this).replaceWith(function() { - var hl = hljs.highlightAuto($(this).text()); - return '
      ' + hl.value + '
      '; - }); }); - }); }); From 52a821f32a920ddf6cbc0aa0b274c09fb2482574 Mon Sep 17 00:00:00 2001 From: George Oyang Date: Thu, 31 May 2012 13:31:53 +0800 Subject: [PATCH 4/5] Update clearly-highlight.js --- clearly-highlight.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/clearly-highlight.js b/clearly-highlight.js index 466f923..c028764 100644 --- a/clearly-highlight.js +++ b/clearly-highlight.js @@ -1,17 +1,16 @@ function loadjs(callback) { - var fileref = document.createElement('script'); - fileref.setAttribute('type', 'text/javascript'); - fileref.onload = callback; - fileref.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); - if (typeof fileref !== 'undefined') { document.getElementsByTagName('head')[0].appendChild(fileref); } + var fileref = document.createElement('script'); + fileref.setAttribute('type', 'text/javascript'); + fileref.onload = callback; + fileref.setAttribute('src', 'http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'); + if (typeof fileref !== 'undefined') { document.getElementsByTagName('head')[0].appendChild(fileref); } } loadjs(function() { - $('#readable_iframe').contents().find('head').append(''); - $.getScript('http://yandex.st/highlightjs/6.1/highlight.min.js', function(){ - - $('#readable_iframe').contents().find('pre').each(function() { - var $this = $(this); + $('#readable_iframe').contents().find('head').append(''); + $.getScript('http://yandex.st/highlightjs/6.1/highlight.min.js', function(){ + $('#readable_iframe').contents().find('pre').each(function() { + var $this = $(this); var children = $this.children(); console.log(children); if(children.length>0){ @@ -51,6 +50,7 @@ loadjs(function() { return '
      ' + hl.value + '
      '; }); } - }); + }); + }); }); From b22ec1356c85618f7f63200dae14e95d93da1429 Mon Sep 17 00:00:00 2001 From: George Oyang Date: Thu, 31 May 2012 13:38:35 +0800 Subject: [PATCH 5/5] Update clearly-highlight.js --- clearly-highlight.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/clearly-highlight.js b/clearly-highlight.js index c028764..aa184c5 100644 --- a/clearly-highlight.js +++ b/clearly-highlight.js @@ -34,15 +34,14 @@ loadjs(function() { } if(!formated){ console.log('formating children'); - children.each(function(){ + children.wrapAll('
        ').each(function(){ formated=true; $(this).replaceWith(function() { var hl = hljs.highlightAuto($(this).text()); return '
      1. ' + hl.value + '
      2. '; }); }); - $this.wrap('
          '); - }else console.log('formating ol li'); + } }else{ console.log('formating not formated code'); $(this).replaceWith(function() {