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

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

问题描述

我正在使用 Automator 创建一个 HTML 页面,一切正常,但我遇到了一个小问题.开始时要求用户提供信息,然后将其设置为变量.该页面是通过使用 Get Specified Text 抓取一些代码并将其复制到剪贴板,获取其中一个变量,然后将它们都放入一个文本文档来创建的.这个过程会重复几次,最终创建一个 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 和/或富文本并且不使用变量(或与其他纯文本操作配合),因此可以在操作之前使用 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.

Run 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

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

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