Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html tidy? #341

Closed
titaniumbones opened this issue Sep 20, 2012 · 19 comments
Closed

html tidy? #341

titaniumbones opened this issue Sep 20, 2012 · 19 comments

Comments

@titaniumbones
Copy link

Hi remy,

Is there already a feature to allow tidying of HTML (e.g. the way the command-line tool "tidy" does)? Mostly I'm just looking for a way to copy in poorly formatted code from a given website, then make it presentable so students can seethe structure a little better. I can do this directly with tidy but it would be cool if jsbin let me (and my students) click a button somewhere... Thanks,
matt

@wamatt
Copy link

wamatt commented Sep 22, 2012

JSBin rocks! I'd switch from JSFiddle, if it supported tidying up HTML, CSS and JS.

@remy
Copy link
Member

remy commented Oct 4, 2012

Maybe adding this would also solve #339?

@wamatt
Copy link

wamatt commented Oct 4, 2012

Yeah, I mean as a principle, it should probably be optional (via a UI flag perhaps), sometimes you want things reformatted (especially if you're cut and pasting from a messy 3rd party site). An other times you want it to leave your code alone

@titaniumbones
Copy link
Author

I'm just imagining a button that calls tidy (or similar) on the
contents of a buffer -- so yeah, it would be optional. How hard do you
think that wd be to implement, remy?

@remy
Copy link
Member

remy commented Oct 4, 2012

Not hard to implement. You pull the tidy library, and run
jsbin.panels.panels.html.setCode(tidy(jsbin.panels.panels.html.getCode()))
(that's just pseudo code).

I've been thinking about (for a few years now) about a plugin/extension
architecture for JS Bin. This might be a nice starting point.

Let me think about it a bit more...

@titaniumbones
Copy link
Author

great, thanks again remy!

@PAEz
Copy link

PAEz commented Mar 24, 2013

I wrote myself a Chrome Extension to do this.....
http://dl.dropbox.com/u/3610419/___JSBin__Beautify.crx
...stripped out a bunch of the extension (still not done) but the Beautify stuff is in there.
Either use the context menu or Ctrl-Alt-Space, works on selection or all code if nothing selected.
If you want to change the beautifier settings then go to the console and youll find them under....
jsbin.settings._PAEz.beautify
...theres an object for css, javascript and html settings.
It uses JS-Beautify ( https://github.com/einars/js-beautify/ )....I couldnt find any js for HTML Tidy.

@wamatt
Copy link

wamatt commented Mar 25, 2013

👍

@JonathanWolfe
Copy link
Contributor

This is pseudo-code because I don't have the time at the moment at work to do a full fork-edit-pr,

But couldn't this be done by doing npm install htmltidy or dropping the repo into /public/plugins/

then:

var htmlTidy = require('htmltidy').tidy;
htmlTidy(jsbin.panels.panels.html.getCode(), function(err, html) {
    jsbin.panels.panels.html.setCode(html)
});

Either run it by key combo (I'm partial to ctrl/cmd+shift+L) or by menu item.

@remy
Copy link
Member

remy commented Oct 27, 2014

There's no require client side in jsbin and getCode is a promise. ie. It's
never as simple as one might think :)

It also needs to ignore markdown and support jade? (Or ignore).

On Mon, 27 Oct 2014 14:42 Jon Wolfe notifications@github.com wrote:

This is pseudo-code because I don't have the time at the moment at work to
do a full fork-edit-pr,

But couldn't this be done by doing

npm install htmltidy

or dropping the repo into /public/plugins/

then:

var htmlTidy = require('htmltidy').tidy;htmlTidy(jsbin.panels.panels.html.getCode(), function(err, html) {
jsbin.panels.panels.html.setCode()});

Either run it by key combo (I'm partial to ctrl/cmd+shift+L) or by menu
item.


Reply to this email directly or view it on GitHub
#341 (comment).

@JonathanWolfe
Copy link
Contributor

I'll try to have a PR in around Tuesday night for this.

I don't know if there's even is a Jade beautifier since it's whitespace dependent. I'll just have it check the panel setting up at the top to see if it's set to HTML and only run if so.

@remy
Copy link
Member

remy commented Oct 27, 2014

The jsbin.state object will tell you which processor is in effect.

On Mon, 27 Oct 2014 15:04 Jon Wolfe notifications@github.com wrote:

I'll try to have a PR in around Tuesday night for this.

I don't know if there's even is a Jade beautifier since it's whitespace
dependent. I'll just have it check the panel setting up at the top to see
if it's set to HTML and only run if so.


Reply to this email directly or view it on GitHub
#341 (comment).

@JonathanWolfe
Copy link
Contributor

Gotcha. I can see the code in my head, I just need some time to pin it down and check it.

@allouis
Copy link
Member

allouis commented Nov 4, 2014

@JonathanWolfe how's this coming along 😺?

@JonathanWolfe
Copy link
Contributor

Work went from busy to crazy so I pushed it to the back burner. Maybe in a week? We're wrapping up 2 projects soon in the next couple days so I should get time again.

@allouis
Copy link
Member

allouis commented Nov 4, 2014

Awesome, that's great, thank you!

@remy
Copy link
Member

remy commented Jun 26, 2015

Done!

@remy remy closed this as completed Jun 26, 2015
@wamatt
Copy link

wamatt commented Jun 27, 2015

pretty cool! ;)

@awangstar
Copy link

Hi @remy love this beautify feature, however for some weird reason. My Command + Shift + L stopped working after couple of times.

I am using chrome on a mac.

Also I am noticing it works if am logged out of my account. I tried making my settings to default ... however when I am logged in the beautify code feature still doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants