自动器添加不需要的换行符 [英] Automator adding unwanted line breaks

查看:89
本文介绍了自动器添加不需要的换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using Automator to create an HTML page and everything works great but I'm running into one small problem. The user is asked for information at the beginning that is then set into variables. The page is created by grabbing some code using Get Specified Text and copying it to the clipboard, getting one of the variables and then putting them both into a text document. This process is then repeated several times, eventually creating an HTML file. I'm running into issues because Automator is creating line breaks (maybe carriage returns?) in between each bit of specified text and each variable. So, what I want to look like this:

<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
.>

这在很多方面破坏了我的页面.有办法防止这些换行吗?

This is breaking my page in a few parts. Is there a way to prevent these line breaks?

推荐答案

从一个动作传递到另一个动作的项目位于列表中,因此似乎设置TextEdit内容可以通过以下方式将各个项目分隔开换行符,这是普通的段落定界符.

The items passed along from action to action are in a list, so it appears that setting the TextEdit contents separates the individual items by a newline, which is the normal paragraph delimiter.

许多文本操作都假定使用TextEdit和/或RTF,并且不使用变量(或与其他纯文本操作配合使用),因此可以在操作之前使用 Run AppleScript 操作转换或连接项目,例如(Mojave):

Many of the text actions assume TextEdit and/or rich text and don’t use variables (or get along with other plain text actions), so a Run AppleScript action can be used before an action to convert or concatenate items, for example (Mojave):

Automator(或TextEdit)实际上不是用于HTML编辑的非常好的工具.您可以查看 BBEdit (简易版是免费的),它也有出色的AppleScript支持.

Automator (or TextEdit for that matter) isn’t really a very good tool for HTML editing. You might take a look at BBEdit (the light version is free), which also has excellent AppleScript support.

运行AppleScript 操作中使用以下命令,以使用指定的定界符(本示例使用空字符串)组合文本:

Use the following in a Run AppleScript action to combine the text using a specified delimiter (this example uses an empty string):

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

这篇关于自动器添加不需要的换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆