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.
" then set myString to myString & "/
– red_menace May 27 '22 at 00:34"`. If you are already wrapping paragraphs, what are you doing to get the newlines?
" repeat while number_of_h3 > 0 set find_h3 to find "^
– Editgrrr May 28 '22 at 04:10(.*)" options {search mode:grep, starting at top:true, returning results:true, wrap around:true} set my_h3 to found text of find_h3 replace my_h3 using (" " & my_h3 & "
") options {starting at top:true, returning results:true, wrap around:true} replace "\\n\\n\\n\\n" using "\\n
" options {starting at top:true, returning results:true, wrap around:true} set number_of_h3 to count "\\n
" end repeat end tell`