Automator添加不需要的换行符

问题描述 投票:0回答:1

我正在使用Automator创建一个HTML页面,一切都很好,但我遇到了一个小问题。在开始时要求用户提供信息,然后将其设置为变量。通过使用获取指定文本抓取一些代码并将其复制到剪贴板,获取其中一个变量然后将它们都放入文本文档来创建页面。然后重复此过程几次,最终创建一个HTML文件。我遇到了问题,因为Automator在指定文本的每个位和每个变量之间创建换行符(可能是回车?)。所以,我想看起来像这样:

<code grabbed using "Get Specified Text" followed by a Variable. And now some more text and another Variable.>

最终看起来像这样:

<code grabbed using "Get Specified Text" followed by a
Variable
. And now some more text and another 
Variable
.>

这在几个部分打破了我的页面。有没有办法防止这些换行?

applescript automator
1个回答
0
投票

从操作传递到操作的项目都在一个列表中,因此设置TextEdit内容似乎将各个项目用换行符分隔,换行符是正常的段落分隔符。

许多文本操作都假设TextEdit和/或富文本,并且不使用变量(或与其他纯文本操作相处),因此可以在转换或连接项目的操作之前使用运行AppleScript操作,例如(Mojave ):

enter image description here

Automator(或TextEdit)对于HTML编辑来说并不是一个非常好的工具。你可以看看BBEdit(轻量版是免费的),它也有很好的AppleScript支持。

编辑:

在运行AppleScript操作中使用以下内容以使用指定的分隔符组合文本(此示例使用空字符串):

on run {input, parameters}
  set separator to "" -- text to separate the items with
  set tempTID to AppleScript's text item delimiters
  set AppleScript's text item delimiters to separator
  set output to input as text
  set AppleScript's text item delimiters to tempTID
  return output
end run
© www.soinside.com 2019 - 2024. All rights reserved.