How to use tidy with stdin?

285 views
Skip to first unread message

zetah

unread,
Dec 13, 2011, 6:36:42 PM12/13/11
to scite-i...@googlegroups.com
Hi,

I run latest SciTE on Linux and wanted to insert tool menu action for tidying current selection (or buffer) without saving buffer to new file

I tried i.e.
...
command.name.10.*=tidy -i -utf8 "$(CurrentSelection)"
command.replace.selection.10.*=2
...

but it does not work. I guess some other method must be used to pipe selection text to tidy

Anyone knows how?

Frank Wunderlich

unread,
Dec 14, 2011, 3:17:54 AM12/14/11
to scite-i...@googlegroups.com
if tidy does not support direct text-parameters (i have not installed it), you can try a workaround using a shell (needed for redirecting)

/bin/sh -c "echo $(CurrentSelection)>tidy"
or
/bin/sh -c "echo $(CurrentSelection)|tidy"

but i found nothing on the manpage, tidy supports stdin-input

HTH

zetah, 14.12.2011 00:36:

zetah

unread,
Dec 14, 2011, 1:06:47 PM12/14/11
to scite-interest
This doesn't work for me

I didn't tried first example, but I expect it to create file named
'tidy'

I tried to pipe (as in your second example) but it doesn't work


On Dec 14, 9:17 am, Frank Wunderlich <frank.wunderl...@gmail.com>
wrote:

Frank Wunderlich

unread,
Dec 15, 2011, 6:41:10 AM12/15/11
to scite-i...@googlegroups.com
as i said, tidy seems not to support direct stdin-input. if your /tmp is
a tmpfs you can create it there and it is not written to disk.

zetah, 14.12.2011 19:06:

klo uo

unread,
Dec 15, 2011, 1:26:49 PM12/15/11
to scite-i...@googlegroups.com
On Thu, Dec 15, 2011 at 12:41 PM, Frank Wunderlich
<frank.wu...@gmail.com> wrote:
> as i said, tidy seems not to support direct stdin-input.

tidy *does* support stdin input

> if your /tmp is a tmpfs you can create it there and it is not written to disk.

can you please provide working example?

Frank Wunderlich

unread,
Dec 15, 2011, 2:27:23 PM12/15/11
to scite-i...@googlegroups.com
klo uo, 15.12.2011 19:26:

> tidy *does* support stdin input
how do you test this? in console? you can run a shell with /bin/sh -c
"command with piping"

> can you please provide working example?
/etc/fstab:
tmpfs /tmp tmpfs defaults,size=1024m 0 0
creates a 1024MB Ramdrive and mount it to /tmp. make sure you dont have
another definition of /tmp

klo uo

unread,
Dec 15, 2011, 3:02:01 PM12/15/11
to scite-i...@googlegroups.com
On Thu, Dec 15, 2011 at 8:27 PM, Frank Wunderlich
<frank.wu...@gmail.com> wrote:
>
> how do you test this? in console?

Yes, in console: `cat sample.html | tidy` works fine.


> you can run a shell with /bin/sh -c "command with piping"

What should be command for piping than?


>> can you please provide working example?
>
> /etc/fstab:
> tmpfs    /tmp    tmpfs    defaults,size=1024m    0    0
> creates a 1024MB Ramdrive and mount it to /tmp. make sure you dont have
> another definition of /tmp

I have no idea what do you mean by this.

I made Lua script that outputs selection to tempfile and replaces
selection by tidy modification. I'm not proud of it, as I find it lame
not being able to figure how to do this without writing to tempfile,
but at least it works and avoids some annoyances like "open save
dialog - figure where to put file - name file - remember to remove it
if not longer needed"

Frank Wunderlich

unread,
Dec 16, 2011, 9:09:20 AM12/16/11
to scite-i...@googlegroups.com
klo uo, 15.12.2011 21:02:

> On Thu, Dec 15, 2011 at 8:27 PM, Frank Wunderlich
> <frank.wu...@gmail.com> wrote:
>> how do you test this? in console?
> Yes, in console: `cat sample.html | tidy` works fine.
>
>> you can run a shell with /bin/sh -c "command with piping"
> What should be command for piping than?
>

/bin/sh -c "cat sample.html | tidy" should work

and then
/bin/sh -c 'echo "<html><body><H1>test</H1></body></html>" | tidy' should also work

now you have to use your selection
/bin/sh -c 'echo "$(CurrentSelection)" | tidy'

the main problem should be dealing with multiple quotes (")

you can try to create a bash-script (eg. check.sh):
#!/bin/sh
echo "$1"|tidy

maybe without the quotes around $1

$(CurrentSelection)=/path/to/check.sh "$(CurrentSelection)"

you can look in the output pane for errors

>>> can you please provide working example?
>> /etc/fstab:
>> tmpfs /tmp tmpfs defaults,size=1024m 0 0
>> creates a 1024MB Ramdrive and mount it to /tmp. make sure you dont have
>> another definition of /tmp
> I have no idea what do you mean by this.
>
> I made Lua script that outputs selection to tempfile and replaces
> selection by tidy modification. I'm not proud of it, as I find it lame
> not being able to figure how to do this without writing to tempfile,
> but at least it works and avoids some annoyances like "open save
> dialog - figure where to put file - name file - remember to remove it
> if not longer needed"

you don't know the linux fstab-file? there you define the filesystems
mountpoints

zetah

unread,
Dec 16, 2011, 12:09:21 PM12/16/11
to scite-interest
I already replied to you that your idea of passing SciTE selection
just like that in `sh` does not work

I don't even want to comment your fstab approach

I assume that you want to help, but please try your theory first,
before publishing to general public


On Dec 16, 3:09 pm, Frank Wunderlich <frank.wunderl...@gmail.com>
wrote:


> klo uo, 15.12.2011 21:02:
>
> > On Thu, Dec 15, 2011 at 8:27 PM, Frank Wunderlich

> > <frank.wunderl...@gmail.com>  wrote:

Reply all
Reply to author
Forward
0 new messages