by Jim » Mon Jul 18, 2011 12:57 am
This .zip file is a Google Chrome browser extension that automatically applies color highlighting to [ code ] tags in SCF posts. (Does not do indentation.) Installation- Download scf_syntax_highliter_1.5.zip below.
- Extract somewhere permanent.
- Open Chrome.
- Open Tools/Extensions.
- Open + Developer mode.
- Click Load Unpacked Extension.
- Browse to extracted folder, click OK.
- Done.
If properly installed, SCF Syntax Highlighter should appear on your Chome Extenions page. Note: Dan likes the line numbers, I do not because the line numbers are included when the selected code is pasted in an editor. This version has line numbering turned on, so you will need to edit the contentscript.js file and remove the "linenums" word to turn them off. It is possible to add an options dialog to toggle linenums on and off, but I have no plans on adding this feature. UseYou don't need to do anything - if a SCF page contains embeded [ code ] tags, the code will be automatically highlighted. HistoryInitial Release
- Update to Version 1.0
- Renamed to scf_syntax_highlight.zip
- Switched highlight engine to google-code-prettify
- Better colors.
- Auto-detects multiple languages.
- Line numbers.
Version 1.5 - 2012-09-30
* Applied mods from John and Dan. * Removed unused .js files. * Removed other extraneous files.
----
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by kyyu » Mon Jul 18, 2011 1:44 am
Cool!  Tried it on FF and worked as advertised.
-
kyyu
-
- Posts: 150
- Joined: Mon Jan 25, 2010 12:32 pm
- Location: Maryland, USA
- Name: Kwok Yu
by Dan Rathbun » Mon Jul 18, 2011 6:55 am
This doesn't work for IE8 ?? EDIT wrote:The first example DOES work in IE8 (and I don't even think I have JQuery installed!)
The bummer is we have to do it for each topic. I'd prefer this to be a user settable for the entire SCF site, perhaps via a right-click context menu.
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Jim » Mon Jul 18, 2011 9:15 am
Dan Rathbun wrote:This doesn't work for IE8 ??
Don't use it, didn't try it. The forum includes jQuery on every page, so using jQuery is the best cross-platform way to do it. I don't know if there is a way to trigger it on a page load, not likely unless it is made into a proper browser add-on. I wrote a jetpack extension to do this, but it requires people to install a 1.5 MB add-on in FF. Also, I am not sure of the current status of jetpack. The idea could be taken further by using something like this to do client-side syntax highlighting.
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Dan Rathbun » Mon Jul 18, 2011 9:20 am
Jim wrote:Dan Rathbun wrote:This doesn't work for IE8 ??
Don't use it, didn't try it.
I did try it on IE8 and it did work. (hence the Edit above.) Jim wrote:The forum includes jQuery on every page, ...
That explains why the JQuery works then.
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Dan Rathbun » Tue Jul 19, 2011 2:35 am
Wondering...
can we embed a conditional statement within a CSS script ??
MSIE lets us have a user (client-side) css file applied to ALL websites, so if I could something like have: if window.location contains "forums.sketchucation.com" then CODE {max-height: auto}
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by thomthom » Fri Jul 22, 2011 12:40 pm
hm... could one make a bookmarklet to add syntax highlighting...?
-

thomthom
- PluginStore Author

-
- Posts: 19457
- Joined: Tue Nov 13, 2007 12:47 pm
- Location: Trondheim, Norway
- Name: Thomas Thomassen
- Operating system: Windows
- SketchUp version: 2019
- License type: Pro
- SketchUp use: other
- Level of SketchUp: Advanced
-
by Dan Rathbun » Fri Jul 29, 2011 11:01 pm
Finally installed Chrome. WOW so fast !!!!
Installed your extension and it works great.
You mentioned something about indentation. I noticed wrapped lines are out-dented. Is this what you meant?
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Dan Rathbun » Sat Jul 30, 2011 2:48 am
Really weird... Chrome installed here: "C:\Documents and Settings\Dan\Local Settings\Application Data\Google\Chrome\Application\chrome.exe" instead of in the Programs path.
Anyone know why?
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Dan Rathbun » Sun Jul 31, 2011 1:05 am
Noticed that the Google Syntax highlighter doesn't colorize the first @ in a module / class @@variable correctly. Here's another test that fails in some hightlighters, when if and unless are used in modifier position: - Code: Select all
puts("Testing") if @value.empty?
warn("Error!") unless $VERBOSE
(Hey if and unless are coloered correctly!) Here's another test that fails in some hightlighters, the periods in ranges don't color correctly: - Code: Select all
for index in 0..256 puts("The value is #{@value[index].to_s}") end # for
(Looks like the second "dot" is a different color.)
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Dan Rathbun » Mon Sep 03, 2012 10:37 pm
I am seeing a warning in my Chrome extensions list, that says support for manifest version 1.0 will be ending. Ref: http://code.google.com/chrome/extensions/manifestVersion.htmlIt says extensions need to be updated to use version 2.
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Jim » Tue Sep 04, 2012 8:36 am
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Dan Rathbun » Tue Sep 04, 2012 9:09 am
After loading.. the title still says ver "1.0"
Line numbers do not appear, and alternating line shading is off.
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by driven » Tue Sep 18, 2012 1:09 am
I noticed this while experimenting on the new site, then tested here, other than the odd colors, this works without the plugin on mac, what about on PC's? john - Code: Select all
def require_all(dirname) begin rbfiles = Dir[File.join(dirname, "*.{rb,rbs}")] $:.push dirname rbfiles.each {|f| Sketchup::require f} rescue puts "could not load files from #{dirname}" end end
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3033
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Krisidious » Tue Sep 18, 2012 2:35 am
A lil OT, I only got here because I thought this might have to do with my alert request. Yeah Chrome is fast... But it grows and grows... independent process for tabs and who knows what else. running one instance of each FF, Chrome and IE9 these are the processes I get. All-Browsers-APV-2.jpg I think FF is by far the biggest beast of all. I might add I have like 3 plugins going on FF.
-

Krisidious
-
- Posts: 6025
- Joined: Mon Oct 22, 2007 1:52 pm
- Location: Springfield, Missouri. USA
- Name: Krisidious
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: architecture
- Level of SketchUp: Advanced
-
by Dan Rathbun » Sun Sep 30, 2012 1:31 am
Fix & bump to v1.4(The Chrome Extensions panel will give you the path to the extension folder, in your USER local APPDATA path.) ISSUES:(1) The forum URL changed after the new site launch, so the manifest.json needed to change: - "matches" value needed a new url entry for the new site.
- "js" value, needed the ref to "jquery-1.6.2.min.js" removed.
New "manifest.json" file: - Code: Select all
{
"manifest_version" : 2, "name" : "SCF Syntax Highlighter", "version" : "1.4", "description" : "Formats SketchUcation <code> areas.", "content_scripts" : [ { "matches" : ["http://sketchucation.com/forums/*","http://forums.sketchucation.com/*"], "js" : ["google-code-prettify/prettify.js", "contentscript.js"], "css" : ["google-code-prettify/prettify.css"], "run_at" : "document_idle", "all_frames" : false } ] }
(2) As John said the Jquery needed to be replaced in "contentscript.js": old "contentscript.js" file: - Code: Select all
//$("#p").hide(); //$("#page-body div p").hide(); //$("#page-body img").hide(); $("code").parent().parent().parent().css("width","100%"); $("code").css("max-height", "800px"); $("code").addClass("prettyprint"); // $("code").addClass("linenums"); prettyPrint(); //$("code").css("border", "1px solid blue"); chrome.extension.sendRequest({}, function(response) {});
new "contentscript.js" file: - Code: Select all
// // SCF [code] Google Syntax Highlighter v1.4+ //
x=document.getElementsByTagName('code'); var newatt; for (i=0;i<x.length;i++) { newatt=document.createAttribute("class"); newatt.value="prettyprint linenums"; x[i].setAttributeNode(newatt); }
prettyPrint();
chrome.extension.sendRequest({}, function(response) {});
 Reload from the Chrome Extensions panel, after making changes. Refresh any pages with code blocks. 
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Jim » Sun Sep 30, 2012 12:48 pm
Thanks much to John and Dan - I have updated the .zip in the first post with your fixes, and simplified the structure.
Hi
-
Jim
- Global Moderator
-
- Posts: 4678
- Joined: Mon Nov 12, 2007 10:13 pm
- Location: ohio
- Name: Jim
- Operating system: Windows
- SketchUp version: 2017
- License type: Pro
- SketchUp use: hobby
- Level of SketchUp: Intermediate
-
by Dan Rathbun » Sun Sep 30, 2012 4:36 pm
Jim wrote:Note: Dan likes the line numbers, I do not because the line numbers are included when the selected code is pasted in an editor.
That's news to me.. because it does not happen to me! I usually use the SELECT ALL button at the top of the codebox. Do you mean if you are copying the whole post ??
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by driven » Sun Sep 30, 2012 5:46 pm
@Jim, how about changing the topic title to just SFC_Forum_SyntaxHighlighter and include other browser versions in your top post. I've done a 'GreaseKit' which works for most 'WebKit' Browsers including 'webDialog'. and a Safari Extension both based on 'google-code-prettify' FireFox should be easy...
john
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3033
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by driven » Sun Sep 30, 2012 10:51 pm
Dan Rathbun wrote:Wondering...
can we embed a conditional statement within a CSS script ??
MSIE lets us have a user (client-side) css file applied to ALL websites, so if I could something like have: if window.location contains "forums.sketchucation.com" then CODE {max-height: auto}
I know this post is old, but to get this to work as a Safari Extension, I had to 'apply to all' then 'whitelist' the forum then 'blacklist all'. On safari the 'whitelist' has precedence over the 'blacklist', so only the forum gets the highlighting... maybe IE has something similar? john
learn from the mistakes of others, you may not live long enough to make them all yourself...
-
driven
- PluginStore Author

-
- Posts: 3033
- Joined: Fri May 01, 2009 11:50 pm
- Name: driven
- Operating system: Mac
- SketchUp version: 2015
- License type: Pro
- SketchUp use: engineering and mechanical design
- Level of SketchUp: Intermediate
by Dan Rathbun » Mon Oct 01, 2012 5:27 am
driven wrote:@Jim, how about changing the topic title to just SFC_Forum_SyntaxHighlighter and include other browser versions in your top post.
A one-stop shop ?
I'm not here much anymore. But a PM will fire email notifications.
-

Dan Rathbun
- PluginStore Author

-
- Posts: 5056
- Joined: Tue Oct 06, 2009 3:06 am
- Location: Florida, USA
- Name: Dan Rathbun
- Operating system: Windows
- SketchUp version: 2015
- License type: Pro
- SketchUp use: education
- Level of SketchUp: Advanced
by Ad Machine » 5 minutes ago
-
Ad Machine
- Robot
-
- Posts: 2012
-
Return to Developers' Forum
|