Well, I've wasted half the morning on this so I hope this saves anyone with this issue some time.

After reading this: http://attaboy.tumblr.com/post/20570385

I bashed my brains out for about an hour before realising that to call a PHP Shell Script you need this around the code:

        #!/usr/bin/php
        <?php
                [... your code...]
        ?>

Obvious to some - not to me!!

Anyway, I've put the complete script to format javascript here for downloading:

http://www.metaclarity.com/dl/JavaScriptFormatPHP.zip

Drop it in this folder:
 ~/Library/Application Support/BBEdit/Unix Support/Unix Filters/

Select your "flat" Javascript. Run the filter (from the !# menu or from Palettes>UNIX Filters) and it should format your Javascript!

Pat







On Jan 17, 2008, at 9:03 AM, Patrick Gilmour wrote:

Hi,

Is there a function in BBEdit to allow a user to indent scripts (Javascript, PHP) in the same way as Format... or Tidy will for HTML?

I often copy scripts from the web and they paste aligned to the left like this:


---
<script type="text/javascript">

var txt=""
function message()

{
try
{
adddlert("Hey There Pilgrim!")
}

catch(err)
{
txt="An error has occurred!"
alert(txt)
}
}
</script>
---

What I'd like is this or some variant (hope the tabs show in this email!):


---
<script type="text/javascript">

var txt=""
function message()

{
        try
        {
                adddlert("Hey There Pilgrim!")
        }

        catch(err)
        {
                txt="An error has occurred!"
                alert(txt)
        }
}
</script>
---

--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>



--
------------------------------------------------------------------
Have a feature request? Not sure the software's working correctly?
If so, please send mail to <[EMAIL PROTECTED]>, not to the list.
List FAQ: <http://www.barebones.com/support/lists/bbedit_talk.shtml>
List archives: <http://www.listsearch.com/BBEditTalk.lasso>
To unsubscribe, send mail to:  <[EMAIL PROTECTED]>

Reply via email to