sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    SCF Forum Syntax Highlighter (v 1.5)

    Scheduled Pinned Locked Moved Developers' Forum
    21 Posts 6 Posters 4.1k Views 6 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      Jim
      last edited by

      @dan rathbun said:

      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.html

      It says extensions need to be updated to use version 2.

      Version 2 added.

      Hi

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          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

          <span class="syntaxdefault"></span><span class="syntaxcomment"># By default, SketchUp automatically loads (using require) all files with<br /># the .rb extension in the plugins directory.  This function can be used<br /># to automatically load all .rb files from a different directory also.  to<br /># use this add a call like the following to a file in the plugins directory<br /># require_all "MyRubyScripts"<br /></span><span class="syntaxdefault">def require_all</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    begin<br />        rbfiles </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Dir</span><span class="syntaxkeyword">[</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> </span><span class="syntaxstring">"*.{rb,rbs}"</span><span class="syntaxkeyword">)]<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">$;.</span><span class="syntaxdefault">push dirname<br />        rbfiles</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">each </span><span class="syntaxkeyword">{|</span><span class="syntaxdefault">f</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">require f</span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">    rescue<br />        puts </span><span class="syntaxstring">"could not load files from #{dirname}"<br /></span><span class="syntaxdefault">    end<br />end</span>
          

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • KrisidiousK Offline
            Krisidious
            last edited by

            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.

            By: Kristoff Rand
            Home DesignerUnique House Plans

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              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:
              {
              
                  "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:

              //$("#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:

              //
              // 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.

              1 Reply Last reply Reply Quote 0
              • J Offline
                Jim
                last edited by

                Thanks much to John and Dan - I have updated the .zip in the first post with your fixes, and simplified the structure.

                Hi

                1 Reply Last reply Reply Quote 0
                • Dan RathbunD Offline
                  Dan Rathbun
                  last edited by

                  @jim said:

                  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.

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    driven
                    last edited by

                    @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...

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      driven
                      last edited by

                      @dan rathbun said:

                      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...

                      1 Reply Last reply Reply Quote 0
                      • Dan RathbunD Offline
                        Dan Rathbun
                        last edited by

                        @driven said:

                        @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.

                        1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 2 / 2
                        • First post
                          Last post
                        Buy SketchPlus
                        Buy SUbD
                        Buy WrapR
                        Buy eBook
                        Buy Modelur
                        Buy Vertex Tools
                        Buy SketchCuisine
                        Buy FormFonts

                        Advertisement