PDA

View Full Version : Coloring a string/line of text in a text



RagingPixels
5 Dec 2013, 2:07 PM
Hello Community,

The program i am currently working on requires me to load a XML File,display it in a container/textarea, let it be validated and mark(color the font background red for example) the spots,where validation failed.(given to me as an XPath expression)

The problem is, i couldnt find an ExtJS internal way of coloring a specific part of some kind of text
and the workaround i thought of, using HTML/CSS for styling, doesnt really work either,
since if i display it in a container which interpretes tags it also tries to interprete the tags in the XMLFile,
which i dont want.

I would very much appreciate any suggestions on how to solve this problem.

scottmartin
5 Dec 2013, 2:47 PM
Can you remove the tags ( Ext.stripTags / Ext.stripScripts )?

If you are unable to use our Ext.form.htmlEditor, tags, or color it with CSS like shown here:
http://jsfiddle.net/HR5N8/

Then I am not sure how you would achieve this.

evant
5 Dec 2013, 3:38 PM
You might want to look at something like code mirror:

http://codemirror.net/demo/preview.html

scottmartin
5 Dec 2013, 4:00 PM
You might want to look at something like code mirror:

On that note .. there is:
https://github.com/ateodorescu/mzExt

Or an alternative for AceEditor
https://github.com/harrydeluxe/extjs-ux

RagingPixels
5 Dec 2013, 4:21 PM
First of all, thank you all for taking the time trying to help me.

sadly none of your suggestions are really what im looking for.

stripping the tags is not a possibility, as they are the subject of validation
and therefore have to be displayed, and why styling with HTML/CSS doesnt work i already stated above;
I need to keep the xml file as plain text as given to me, just coloring the validation errors.

HTML Editors be it the extjs one, or codemirror etc would confuse the User unnessecarily,
as it is just for display, and the text should not be editable.

evant
5 Dec 2013, 4:57 PM
Oh, you just want to highlight it and it's static? Even easier (this is the first one I pulled from google, there's probably way more):

http://alexgorbatchev.com/SyntaxHighlighter/manual/brushes/xml.html

RagingPixels
6 Dec 2013, 2:47 AM
well, static is not quite right, as i have to dynamically accept and display any xml file the user uploads,
but the syntaxhighlighter might be something i can work with regardless, ill have a look into it.