简体   繁体   中英

how can I get my text area to auto format text

I want to know how to make a text area in a browser into a programmers text editor. For anyone that uses textmate -- I basically want it web-based. for anyone that uses notepad++ -- same idea as above.

I know how to make a text area using html. what I dont know is how to tag the text areas. for instance. in notepad++ and textmade, I can insert the <> tags and it will highlight the text blue. How can I achieve this, live, in a browser. I already know how to parse it after the text has been posted. I want it to be parsed while the user is typing it.

EditArea非常好。

除了EditArea,还有CodeMirrorMozilla的Bespin

EDIT: I misunderstood the question a little. Jump to ORIGINAL ANSWER if you are curious.

EDIT2: My answer is how to provide SYNTAX HIGHLIGHTING (what is specified in the question itself). Highlighting individual characters unrelated to the syntax requires trivial javascript. This is also distinct from 'auto format' which is commonly interpreted to mean 'adjust my indent levels so it all looks good'.

This is a difficult task, but not as impossible as it seems. Once again, TextMate comes to our rescue but in a different fashion.

In TextMate, open the bundle editor and look at the language definition for HTML. Those are regexes that process the document and assign a 'scope' to each piece.

'Simply' parse that language definition format into the various components, and then use the regexes themselves like TextMate does to assign a scope/color. Piece of cake, right? :)

I would personally start with the most lightweight open source rich text editor you can find, then hack it into that. Or ya know, whatever floats your boat.

I hope that gave you some good ideas.

ORIGINAL ANSWER:

For Firefox, you can install the plugin 'It's All Text' from here: https://addons.mozilla.org/en-US/firefox/addon/4125/

It works for me with 3.6.12. Set the path in preferences to TextMate (or whatever), and optionally set a hotkey or adjust the other settings to your liking. Be default, when your cursor is over a Textarea, a small button saying "Edit" will appear and open the contents of the Textarea in your editor. Saving will put the data back into the Textarea.

I hope this helps.

JSMinNpp插件仅用于javascript自动格式化http://sourceforge.net/projects/jsminnpp/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM