applescripts。如何在文本文档中的某些行末尾添加text_object/code片段?
我正在使用AppleScript来查找某些字符或BBEDIT中的某些字符或字符串,以加快从Microsoft Word文档中剥离内容的过程,然后将其包裹在HTML中,然后再将其包装到CMS中。当它是替换类型的命令时,大多数都很好。但是,我不知道如何用关闭的H标签修改一条线的末端。
例如,以下行在p标签中包装段落做得很好: 使用“</p> \\ n< p>”替换“ \\ n \\ n”“”在文本文档1选项的文本1中搜索{从顶部开始:true}
,我有一个解决方案将H标签添加到A行的正面。但是,我不知道如何用关闭的H标签修改一条线的结束,这就是我希望获得一些帮助的方法。
我正在寻找遵循此逻辑的内容:“如果一行以< h3>
开头,则将</h3>
添加到行的末尾。”或“当行以< h3>
开头时,将下一个\\ n
替换为</h3> \\ n
。”
如果在Applescript中有些可行(而不是外壳),那将是理想的选择,因为我对此是相当陌生的,并且还没有对自己的贝壳进行过任何知识。
I'm using an Applescript to find-and-replace certain characters or strings of characters in BBEdit to speed up the process of ripping content out of a Microsoft Word document and wrapping it in html before it goes into a CMS. Most of this is fine when it's a replace-all type of command. However, I can't figure out how to amend the end of a line with a closing H tag.
For instance, the following line does a great job of wrapping paragraphs in P tags:replace "\\n\\n" using "</p>\\n<p>" searching in text 1 of text document 1 options {starting at top:true}
And I have a solution for adding h tags to the front of the a line. However, I can't figure out how to amend the end of a line with a closing h tag, and that's what I'm hoping to get some help with.
I'm looking for something that follows this logic: "If a line begins with <h3>
, add </h3>
to the end of the line." OR "When a line begins with <h3>
, replace the next \\n
with </h3>\\n
."
If there's something that works within the Applescript (rather than a shell), that would be ideal, as I am fairly new to this and haven't taught myself anything about shells just yet.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用BBEDIT内置的正则表达式支持来有效地解决此问题,例如:
这为所有
H3
元素添加了关闭标签。You can solve this efficiently using BBEdit's built in regular expressions support, like so:
This adds closing tags for all
h3
elements.在我的原始帖子中的一位受访者指出我朝正确的方向指出之后,我弄清楚了。 很有帮助。
( Google组中的此交换也 t知道这是否是“正确的”,但它可以做我希望它能做的事情:它在每条线以特定的东西开头的每一行中添加了一个字符串。
I figured it out after one of the respondents to my original post pointed me in the right direction. (This exchange in a Google Group was also pretty helpful.)
I don't know if this is "correct" but it does what I was hoping it could do: It adds a string to the end every line that begins with something specific.