Given my tests, the culprit is not the version 5.5.3, it’s that your source documents aren’t using the same structure than the “old” one.
Remember.
At first you gave a sample file with some lines starting with “" then you posted a file in which there were no lines starting with "” but by " *".
I edited your text so that it contain the two kinds of lines and only the ones starting with " " were correctly extracted.
My guess is that you are now treating texts with lines starting with "".
I edited the script so that it treats both cases but I repeat that, as far as I know, the original one (note mine) works perfectly with 5.5.3.
-- Since there's only one style to preserve in the document, this version of the script does all the editing within AppleScript and replaces the text in the document with the finished result.
-- Tested with Pages 5.5.2 and 5.5.3.
on main()
script o
property paras : {}
end script
tell application "Pages" to set o's paras to paragraphs of body text of document 1
-- This variable is set to 'true' when a "0.0 deg." line is encountered and there may be an associated follow-up paragraph.
set expectingFollowup to false
-- Go through the paragraph list, bracketing the paragraphs to keep with returns (except that follow-up paragraphs only get postpended returns) and zap everything else.
repeat with i from 1 to (count o's paras)
set thisPara to item i of o's paras
if (thisPara ends with "- Bill") then
set item i of o's paras to return & text from word 1 to -1 of thisPara & return
set expectingFollowup to false
else if (((thisPara begins with " *") or (thisPara begins with "*")) and (thisPara contains "0.0 deg.")) then # ADDED two parens
set item i of o's paras to return & thisPara & return
set expectingFollowup to true
else if (thisPara begins with " *") or (thisPara begins with "*") then
set item i of o's paras to missing value
set expectingFollowup to false
else if ((expectingFollowup) and ((count thisPara) > 10)) then
set item i of o's paras to thisPara & return
set expectingFollowup to false
else
set item i of o's paras to missing value
end if
end repeat
-- Convert what's left to a single text.
set astid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ""
set editedText to (text of o's paras) as text
set AppleScript's text item delimiters to astid
-- Replace the text in the document with the result.
tell application "Pages" to set body text of document 1 to text 2 thru -1 of editedText
end main
main()
I also made a change : as begins and starts are synonymous, I replaced starts by begins but it’s just matter of taste.
Oops, I forgot to paste the resulting text.
Friday, 27 Mar 2015 - Bill
*Here is the title (some data, 0.9 deg.) -
Text here… until a new one!
*Here is the title (some data, 0.0 deg.) -
Text here… until a new one!
Saturday, 28 Mar 2015 - Bill
*Here is the title (some data, 0.2 deg.) -
Text here… until a new one!
*Here is the title (some data, 0.0 deg.) -
Text here… until a new one!
Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) mardi 25 août 2015 12:30:15