简体   繁体   English

如何使我的文本区域自动设置文本格式

[英]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. 对于使用textmate的任何人-我基本上都希望基于Web。 for anyone that uses notepad++ -- same idea as above. 适用于使用notepad ++的任何人-与上述相同的想法。

I know how to make a text area using html. 我知道如何使用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. 在notepad ++和textmade中,我可以插入<>标记,它将以蓝色突出显示文本。 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). EDIT2:我的答案是如何提供语法突出显示(在问题本身中指定了什么)。 Highlighting individual characters unrelated to the syntax requires trivial javascript. 突出显示与语法无关的单个字符需要简单的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. TextMate再次以不同的方式来帮助我们。

In TextMate, open the bundle editor and look at the language definition for HTML. 在TextMate中,打开包编辑器,然后查看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. “简单地”将语言定义格式解析为各种组件,然后像TextMate一样使用正则表达式本身来分配范围/颜色。 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/ 对于Firefox,您可以从此处安装插件“ It's All Text”: https : //addons.mozilla.org/en-US/firefox/addon/4125/

It works for me with 3.6.12. 它适用于我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. 将首选项中的路径设置为TextMate(或其他),并根据需要选择设置热键或调整其他设置。 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. 默认情况下,当光标位于Textarea上时,将出现一个小按钮,显示“ Edit”,并在编辑器中打开Textarea的内容。 Saving will put the data back into the Textarea. 保存会将数据放回到Textarea中。

I hope this helps. 我希望这有帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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