zveřejňuji kód, který jsem si právě cvičně napsal v AppleScriptu.
Pomocí tohoto skriptu odstraníte v dokumentu vícenásobné mezery v textovém editoru Pages.app na macOS.
Pozor kód odstraňuje všechny mezery i pevné a kód není nijak optimalizován, je napsán „na první dobrou“.
Tak třeba se někomu bude hodit
Kód: Vybrat vše
-- Smazání zdvojených mezer v Pages.app 5.5 a vyšších
-- © 2017 František Erben
-- Licence: BSD licence (https://cs.wikipedia.org/wiki/BSD_licence)
on Spaces()
set again to false
tell application id "com.apple.iWork.Pages"
tell the front document
tell the body text
set allCharsList to every character
set maxCount to count of items of allCharsList
set ii to maxCount
repeat until ii = 0
set theChar to allCharsList's item ii
if theChar as string is equal to " " then
set nextChar to allCharsList's item (ii - 1)
if nextChar as string is equal to " " then
set character ii to character (ii - 1)
set ii to ii - 2
set again to true
end if
end if
set ii to ii - 1
end repeat
end tell
end tell
end tell
return again
end Spaces
repeat
set result to my Spaces()
if result is equal to false then exit repeat
end repeat