🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #15287

Replacing formatted text with HTML tags

#15287
From: DOR_Web
Date: Wed, 10 Dec 2003 20:41
40 lines
2076 bytes
I need a quick answer to this one. Project is due on Friday.

My InDesign document is tagged with XML tags for export to a database. This database will display info on the Web.

The original document contains formatted text (ie. bold, italic, etc.). To display this properly on the Web, the formatting needs to be replaced by HTML tags. I've got this (see script below).

My problem is that when the bold appears at the start of a paragraph where a new XML tag is located, the script inserts the bold tag outside of the XML tag.

The ideal solution would have been to convert the formatting prior to tagging the document. However, I don't have time to go back and retag 300-plus pages by Friday.

Any help is appreciated.

Here's the script:

tell application "InDesign 2.0.2"
	set myDoc to active document
	set myFrame to parent text frame of selection
	tell myDoc
		try
			repeat
				set myText to search myDoc with find attributes {font style:"Bold"}
				select myText
				set font style of selection to "Roman"
				set myPaste to selection
				set contents of selection to "" & myPaste & ""
			end repeat
		end try
		try
			repeat
				set myText to search myDoc with find attributes {font style:"Italic"}
				select myText
				set font style of selection to "Roman"
				set myPaste to selection
				set contents of selection to "" & myPaste & ""
			end repeat
		end try
		display dialog "All finished!�
		Click OK to continue."
	end tell
end tell
Technical Details
Message-ID: <2ccedc96.-1@webx.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f939a,f637110241d8c372,start
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-12-10 13:07:59 PST
From: DOR_Web@adobeforums.com
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!webx
Newsgroups: adobe.scripting.indesign
Subject: Replacing formatted text with HTML tags
Message-ID: <2ccedc96.-1@webx.la2eafNXanI>
Date: Wed, 10 Dec 2003 12:41:03 -0800
Lines: 48
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit