adding tags to text attributes

Hello,
i want to structurize a document (rtf,txt) with tags (to insert before of a particular text-attribute), whenever the script finds: bold, italic, UPPERCASE, punctuation (, ; . . - ( ) to apply for the entire paragraph in a document. (and to extend for the entire document)
There exists no entry for these attiributes in the applescript dictionary! help!
How can i do in my case?? using some special applications?

set vol_0 to "[[volm 1]]"
set sil_1 to "[[slnc 150]]" -- ', '  , ' ('   ,   '. ',  
--set sil_2 to "[[slnc 250]]" --'--','-'
set sil_3 to "[[slnc 500]]" --1 or more empty paragraphs
--set vol_1 to "[[volm 1.5]]" --italic
set vol_2 to "[[volm 2]]" --bold
--set vol_3 to "[[volm 3]]" --title

set the_chars to {",", "(", "-", ":", "¢", "."}
--set bold_y to {}
set title_y to {40}
--set allpara to every paragraph of document 1
tell application "TextEdit"
	--tell application "Journler"
	--set E to first item of (get selected entries)
	set E to document 1
	--set hh to name of E
	--set this_para to every paragraph of E
	set paragraph 1 of E to (vol_2 & return & first paragraph of E & return & vol_0 & return as text)
	repeat with I from 0 to count paragraphs of E -- of document 1
		set this_para to paragraph I of E -- of document 1
		if this_para is not "\n" then
			repeat with ah from 1 to count characters of this_para
				set this_char to character ah of this_para
				if this_char is in the_chars then
										set character ah of paragraph I of E to ¬
						(this_char & sil_1 as string)
					exit repeat
				end if
			end repeat
			repeat with x from 1 to count words of this_para
				set this_w to word x of this_para
				--set this_w to this_w as rich text
				try
					set the_sz to size of (character 1 of word x of paragraph I of E)
					if the_sz > 14 and the_sz is in title_y then
						set this_para to vol_2 & this_para & return & vol_0
						set cc to count words
						exit repeat
					end if
				end try
			end repeat
		else if this_para is "\n" then
			set this_para to (sil_3 as text)
		end if
	end repeat
	set the last paragraph of E to (last paragraph of E & return & sil_1 & return & sil_3 & return & vol_2 & return & vol_0 as text)
	--set thePP to path of document 1
	set thecont to every paragraph of document 1 as text
	set the clipboard to thecont
	tell application "GhostReader" to activate
end tell

Any news on this script? Thanks.

Hi oa,

The attribute run used to contain bold and italics. I think it depends on the application. I think there was a way though to get/set bold and italics with TextEdit. Need to look into it again.

Maybe it was with ui scripting.

Edited: here is the rtf file with bold and italics:

b stands for bold. b0 is the ending of bold. You know what i means.
Now what?

Maybe something like this:

tell application "TextEdit"
	--font of character 1 of front document
	every word of front document whose font contains "Bold"
end tell
--> {"jumps"}

gl,
kel

If my memory is OK, if we want to use vanilla AppleScript, we must set the name of the font applied to chunks of text.

With Helvetica we may apply :
font:“Helvetica”
font:“Helvetica-Bold”
font:“Helvetica-Oblique”
font:“Helvetica-BoldOblique”

If I run this script :

tell application "TextEdit" to tell document 1
	set theAttributeRuns to attribute run of every paragraph
	properties of attribute run of every paragraph
	set font of characters of paragraph 1 to "Helvetica-BoldOblique"
	set theAttributeRuns to attribute run of every paragraph
	properties of attribute run of every paragraph
end tell

on a small sample text, I get :

tell application "TextEdit"
	get attribute run of every paragraph of document 1
		--> {{"En ", "gras
"}, {"En normal
"}, {"En italique", "
"}, {"En gras italique"}}
	get properties of attribute run of every paragraph of document 1
		--> {{{font:"Helvetica-Bold", color:{0, 0, 0}, class:text, size:12.0}, {font:"Helvetica-BoldOblique", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica-Oblique", color:{0, 0, 0}, class:text, size:12.0}, {font:"Helvetica", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica-BoldOblique", color:{0, 0, 0}, class:text, size:12.0}}}
	set font of every character of paragraph 1 of document 1 to "Helvetica-BoldOblique"
	get attribute run of every paragraph of document 1
		--> {{"En gras
"}, {"En normal
"}, {"En italique", "
"}, {"En gras italique"}}
	get properties of attribute run of every paragraph of document 1
		--> {{{font:"Helvetica-BoldOblique", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica-Oblique", color:{0, 0, 0}, class:text, size:12.0}, {font:"Helvetica", color:{0, 0, 0}, class:text, size:12.0}}, {{font:"Helvetica-BoldOblique", color:{0, 0, 0}, class:text, size:12.0}}}
end tell

As you see, there is no need to use GUIScripting.

Yvan KOENIG (VALLAURIS, France) mardi 14 octobre 2014 19:15:21

Hi Yvan,

Yes, I was just getting there. I wanted to try it before someone gave the answer! :smiley:

Just got the oblique part:

tell application "TextEdit"
	--font of character 1 of front document
	every word of front document whose font contains "Oblique"
	--font of every word of front document
end tell
--> {"lazy"}

I knew you had the answer! :smiley:

Have a good day,
kel