Subscribe Bookmark RSS Feed

text explorer: exporting highlighted "show text" result to ms word or pdf

saitcopuroglu

Community Trekker

Joined:

Sep 29, 2014

 

Dear community,

Is there a way to export the results shown in picture (show text of chosen terms/phrases) to a word or pdf format keeping the "text highlight" function as seen on picture? A JSL would be perfect.

 

Screen Shot 2017-06-20 at 17.25.49.png

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution
html = "";
wordlist = {"room", "food", "staff", "clean"};
color = {"FFFF00", "00FFFF", "00FF00", "C0C0FF"};
For Each Row(
	html = html || "<H3>" || Titles || "</H3>"; // H1 or H2 is even bolder
	rowtext = Reviews; // rowtext will be modified in the loop to add the color
	for( iWord=1,iWord<=nitems(wordlist),iWord++, // each word, one at a time
		rowtext = regex(
			rowtext, // input to regex
			"\!\b("||wordlist[iWord]||")\!\b", // find a word with word boundaries on each side
			"<span style='background-color: #"||color[iWord]||"'>\1</span>", // \1 is the word
			IgnoreCase, GlobalReplace) // match food or Food, and multiple occurrences
	);
	html = html  || rowtext || "<br><br>"; // append each story and some blank lines
);

// add minimal HTML around the doc
html = "<html><body>"||html||"</body></html>";

// save and display
filename = savetextfile("$temp/deleteme.html", html);
open(filename);
Craige
4 REPLIES
billw_jmp

Staff

Joined:

Jul 2, 2014

Would be you be open to some sort of screen capture and then copy and paste for a short term fix.  There is the Windows Snipping Tool which is free and Snagit is another option, but that has an associated cost.  You can use these tools to select just the portion of the image you want and then copy and paste in a document as needed.

 

HTH

Craige_Hales

Staff

Joined:

Mar 21, 2013

pretty sure the text explorer "show text" window can't save the coloring. You could write some JSL to get the effect:

docs = "Text for Words:  brown fox

the quick brown fox jumped over the lazy dogs back [1]

quick brown dog [2]

lazy fox jumped [3]

brown the lazy fox [5]";

// pick out the list of special words
wordlist = words(regex(docs,"Text for Words:(.*?)[\!n\!r]","\1")); // {"brown", "fox"}

// insert html into the documents to color the words
color={"FFFF00","00FFFF","00FF00","8080FF"};
for( iWord=1,iWord<=nitems(wordlist),iWord++,
	docs = regex( docs, "\!\b("||wordlist[iWord]||")\!\b", "<span style='background-color: #"||color[iWord]||"'>\1</span>", GLOBALREPLACE)
);

// insert breaks for newlines
docs = regex(docs,"[\n\r]","<br>",GLOBALREPLACE);

// add minimal HTML around the doc
docs = "<html><body>"||docs||"</body></html>";

// save and display
filename = savetextfile("$temp/deleteme.html", docs);
open(filename);

formatted HTML with high-lighted wordsformatted HTML with high-lighted words

Craige
saitcopuroglu

Community Trekker

Joined:

Sep 29, 2014

Thank you, this is a sure solution but the JSL level is so high for me. May I request to adapt the script for attached table for words "room" food" "staff" "clean" ? From there on I guess I can do it for my table. Many many thanks in advance

Craige_Hales

Staff

Joined:

Mar 21, 2013

Solution
html = "";
wordlist = {"room", "food", "staff", "clean"};
color = {"FFFF00", "00FFFF", "00FF00", "C0C0FF"};
For Each Row(
	html = html || "<H3>" || Titles || "</H3>"; // H1 or H2 is even bolder
	rowtext = Reviews; // rowtext will be modified in the loop to add the color
	for( iWord=1,iWord<=nitems(wordlist),iWord++, // each word, one at a time
		rowtext = regex(
			rowtext, // input to regex
			"\!\b("||wordlist[iWord]||")\!\b", // find a word with word boundaries on each side
			"<span style='background-color: #"||color[iWord]||"'>\1</span>", // \1 is the word
			IgnoreCase, GlobalReplace) // match food or Food, and multiple occurrences
	);
	html = html  || rowtext || "<br><br>"; // append each story and some blank lines
);

// add minimal HTML around the doc
html = "<html><body>"||html||"</body></html>";

// save and display
filename = savetextfile("$temp/deleteme.html", html);
open(filename);
Craige