Re: Make new HTML document from template in AppleScript: How?

2021-10-10 Thread Christopher Stone
> On Oct 07, 2021, at 23:11, Sonic Purity  wrote:
> Note: i write my stories in TE—that’s non-negotiable.

Hey Sonic,

Agh...

At least take a look at Jedit Ω (1,840 Yen ~ $16.00 USD).

http://www.artman21.com/en/jeditOmega/

It will do what TextEdit will do and a whole lot more.

You have to tweak some of the keyboard shortcuts, but like BBEdit Jedit has 
preferences for that.


--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/1F100C9C-85D1-44AF-93DD-A30DD2DC5052%40gmail.com.


Re: Make new HTML document from template in AppleScript: How?

2021-10-07 Thread Sonic Purity
Yeah, Markdown is interesting, but with over 1.8 million words across a 
couple dozen novels plus assorted novellas, novelettes, and a short story 
or two already written in TextEdit, i’m already invested in doing things as 
my odd personal mix of normal rich text formatting plus Sonic’s Quirky 
Markup.

The issue in this thread’s long resolved, and i’ve made excellent progress 
with my AppleScript, so i’ll start a new conversation on a new sticking 
point.

Thanks All!

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/831446af-2bf5-4baf-a541-0e1a0a67514fn%40googlegroups.com.


Re: Make new HTML document from template in AppleScript: How?

2021-10-06 Thread Jan Erik Moström
On 6 Oct 2021, at 7:49, jj wrote:

Sonic,

While I read that

> i write my stories in TE—that’s non-negotiable

but should you decide to check out jj's suggestion and start using Markdown

> I would just suggest that before you start the journey, you check the 
> Markdown language: https://en.wikipedia.org/wiki/Markdown and the BBEdit 
> manual for Markdown.

I suggest that you add Marked to your toolbox, it's an excellent tool for 
converting Markdown into various other formats, combining separate markdown 
files into one document, etc, etc. I use BBEdit + Marked for a lot of my 
writing (non-fiction) and for me it's a very nice combination.

Unfortunately, I haven't used TextEdit for many years so I can't really offer 
any insight in how to use TE + BBEdit best in your case.

= jem

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/2C99ED4B-5E01-470E-8006-E0DBE5DF0077%40mostrom.pp.se.


Re: Make new HTML document from template in AppleScript: How?

2021-10-05 Thread jj
Hi Sonic,

Thank you for your long overview. It helps understand the traveler and the 
road ahead.

I would just suggest that before you start the journey, you check the 
Markdown language: https://en.wikipedia.org/wiki/Markdown
and the BBEdit manual for Markdown.

BBEdit fully supports Markdown and has built-in Markdown-to-HTML preview 
and conversion.

Today, this is probably the most common way to produce textual content for 
the web and it's way easier to use than AppleScript.

Bon voyage.

Jean Jourdain

On Wednesday, October 6, 2021 at 6:05:14 AM UTC+2 sonic...@gmail.com wrote:

> Thank you Chris and Jean for your responses. Jean’s in particular suggests 
> to me it’s time to take a step or several back and share with you a big 
> picture description of the overall automation project, since i may be going 
> about things inefficiently due to my inexperience in some areas.
>
> Here is an overview me and of what i’m doing, in English:
>
>
> *My Background*
>
> Despite my EECS degree, i’m more EE than CS. It was long enough ago that 
> the languages i dealt with were Basic and Fortran. From those, i have an 
> understanding of loops, conditional branches, variables, constants, etc. 
> Apart from AppleScript, i haven’t dealt with object-oriented programming. I 
> learned some Unix at UC Berkeley decades before Apple got into it, hence 
> i’m comfortable on the command line. I’ve written some very simple, very 
> short shell scripts.
>
> I’m good with HTML and CSS, but for various reasons have avoided 
> Javascript, having done almost no work with it. I haven’t used any other 
> programming or scripting languages.
>
> In terms of AppleScript, i’m at neophyte level, or just beyond. I’ve made 
> a few short, basic ones on my own. This project is by far the most 
> ambitious i’ve attempted. Even with resources like the BBEdit User Manual’s 
> section on scripting the clipboard, i still can’t get a basic clipboard 
> copy to work (for one example).
>
>
> *Project: Big Picture Overview*
>
> Convert my master fiction novel manuscripts into web pages for my personal 
> site.
>
>
> 1) Write, edit, finalize story in TextEdit (TE). Result: master manuscript 
> in RTF format.
>
> 2) Use TE to convert to HTML. Result: One HTML document which is 
> syntactically-correct and validates, but is semantically a mess.
>
> 3) Process TE HTML document to make it semantic and have all the classes 
> etc. i require for my CSS.
>
> 4) Create a new HTML document in BBEdit for each story chapter from a 
> template, with all the header and navigation stuff.
>
> 5) Paste the chapter HTML from the TE HTML document into the body HTML 
> area of the newly-created BBEdit individual chapter HTML document. Populate 
> some navigation information.
>
> 6) Repeat 4 & 5 for each chapter.
>
> 7) Create a story main/TOC page from a different BBEdit HTML document 
> template. Paste in Chapter titles and links from a document made around 
> step 4.
>
> 8) Populate remaining navigation information in all the chapter HTML files 
> from finalized information from the TOC document.
>
>
> Note: i write my stories in TE—that’s non-negotiable. Having experimented 
> with working with the original TE RTF in BBEdit, i quickly found that 
> wholly unworkable. Having experimented with various options to get from TE 
> RTF into HTML, i found TE’s “built in” Cocoa HTML Writer the least-worst 
> option.
>
>
> *Project: Manual or Semi-Automated Processing*
>
> Step 1) above is straightforward and outside the scope of this 
> discussion—no automation possible nor needed.
>
> Step 2) above is one fast and straightforward menu command—no automation 
> needed nor desired.
>
>
> Step 3) is a Very Big Deal. I start with TE HTML that looks generally like 
> this sample:
>
> Dating Dilemmas
>
> 
>
> 
>
> * The Big Step *
>
> Nate was nervous—no question. […long paragraph text 
> here…]
>
> He wasn’t shy about his FAness and wasn’t shy at all behind 
> a technology wall.[…long paragraph text here…]
>
> 
>
> This was the 3rd. time he’d come out to the monthly 
> Gravitational Goddesses Get-Together. […long paragraph text here…]
>
> … on and on for some 700,000 characters/130,000 words
>
>
> Once i’m done, before splitting into chapters, this same sample looks like:
>
> Dating Dilemmas
>
> by Sonic Purity
>
> 
>
>
> 
>
> The Big Step
>
> Nate was nervous—no question. […long paragraph text 
> here…]
>
> He wasn’t shy about his FAness and wasn’t shy at all 
> behind a technology wall.[…long paragraph text here…]
>
>
> This was the 3rd. time he’d come out to the monthly 
> Gravitational Goddesses Get-Together.[…long paragraph text here…]
>
>
> There are about 34 steps in Step 3), covering all sorts of special CSS 
> formatting not shown in my brief example. I’ve already automated what i can 
> with Text Factories. A number of things have to be done manually.
>
> When i’m done, there’s only one  in the entire TE HTML document, which 
> is the story title. Each 

Re: Make new HTML document from template in AppleScript: How?

2021-10-05 Thread Sonic Purity


Thank you Chris and Jean for your responses. Jean’s in particular suggests 
to me it’s time to take a step or several back and share with you a big 
picture description of the overall automation project, since i may be going 
about things inefficiently due to my inexperience in some areas.

Here is an overview me and of what i’m doing, in English:


*My Background*

Despite my EECS degree, i’m more EE than CS. It was long enough ago that 
the languages i dealt with were Basic and Fortran. From those, i have an 
understanding of loops, conditional branches, variables, constants, etc. 
Apart from AppleScript, i haven’t dealt with object-oriented programming. I 
learned some Unix at UC Berkeley decades before Apple got into it, hence 
i’m comfortable on the command line. I’ve written some very simple, very 
short shell scripts.

I’m good with HTML and CSS, but for various reasons have avoided 
Javascript, having done almost no work with it. I haven’t used any other 
programming or scripting languages.

In terms of AppleScript, i’m at neophyte level, or just beyond. I’ve made a 
few short, basic ones on my own. This project is by far the most ambitious 
i’ve attempted. Even with resources like the BBEdit User Manual’s section 
on scripting the clipboard, i still can’t get a basic clipboard copy to 
work (for one example).


*Project: Big Picture Overview*

Convert my master fiction novel manuscripts into web pages for my personal 
site.


1) Write, edit, finalize story in TextEdit (TE). Result: master manuscript 
in RTF format.

2) Use TE to convert to HTML. Result: One HTML document which is 
syntactically-correct and validates, but is semantically a mess.

3) Process TE HTML document to make it semantic and have all the classes 
etc. i require for my CSS.

4) Create a new HTML document in BBEdit for each story chapter from a 
template, with all the header and navigation stuff.

5) Paste the chapter HTML from the TE HTML document into the body HTML area 
of the newly-created BBEdit individual chapter HTML document. Populate some 
navigation information.

6) Repeat 4 & 5 for each chapter.

7) Create a story main/TOC page from a different BBEdit HTML document 
template. Paste in Chapter titles and links from a document made around 
step 4.

8) Populate remaining navigation information in all the chapter HTML files 
from finalized information from the TOC document.


Note: i write my stories in TE—that’s non-negotiable. Having experimented 
with working with the original TE RTF in BBEdit, i quickly found that 
wholly unworkable. Having experimented with various options to get from TE 
RTF into HTML, i found TE’s “built in” Cocoa HTML Writer the least-worst 
option.


*Project: Manual or Semi-Automated Processing*

Step 1) above is straightforward and outside the scope of this 
discussion—no automation possible nor needed.

Step 2) above is one fast and straightforward menu command—no automation 
needed nor desired.


Step 3) is a Very Big Deal. I start with TE HTML that looks generally like 
this sample:

Dating Dilemmas





* The Big Step *

Nate was nervous—no question. […long paragraph text here…]

He wasn’t shy about his FAness and wasn’t shy at all behind a 
technology wall.[…long paragraph text here…]



This was the 3rd. time he’d come out to the monthly 
Gravitational Goddesses Get-Together. […long paragraph text here…]

… on and on for some 700,000 characters/130,000 words


Once i’m done, before splitting into chapters, this same sample looks like:

Dating Dilemmas

by Sonic Purity






The Big Step

Nate was nervous—no question. […long paragraph text 
here…]

He wasn’t shy about his FAness and wasn’t shy at all behind 
a technology wall.[…long paragraph text here…]


This was the 3rd. time he’d come out to the monthly 
Gravitational Goddesses Get-Together.[…long paragraph text here…]


There are about 34 steps in Step 3), covering all sorts of special CSS 
formatting not shown in my brief example. I’ve already automated what i can 
with Text Factories. A number of things have to be done manually.

When i’m done, there’s only one  in the entire TE HTML document, which 
is the story title. Each chapter starts with  and runs until the next 
opening —and Chris will be familiar with this from a question i asked 
here several weeks ago.


Steps 4-8 i’ve been doing manually/partially automated. They’re what i’m 
trying to more fully automate now, as most of it is repetitive work with 
predictable, repeatable actions. Here’s how i do it manually:


Somewhere between Steps 3 & 4: Find All chapter headings 
[content], Extract to new document. Do some pre-processing for 
their eventual use on the TOC page and to get a story total chapter count 
from the line count. (This part is already automated.)


Step 4: New HTML document in BBEdit, selecting my individual story chapter 
template and entering the story title in the dialog. Using Includes, BBEdit 
fills in the current year (for copyright) and the 

Re: Make new HTML document from template in AppleScript: How?

2021-10-05 Thread jj
Using AppleScript to create HTML templates is an option and Christopher's 
example is excellent in that regard.

BBEdit also offers some powerful tools to create/use customizable HTML 
templates with AppleScript placeholders.

Check the BBEdit manual for:

  • Chapter 11: BBEdit HTML Tools, Templates, p. 312
  • Appendix C: Placeholders and Include Files, p. 413 
  • Appendix C: Including AppleScripts, Including Unix Scripts, p. 421
  
Similar placeholder techniques can be used to create HTML Clippings, see 
the manual:

  • Chapter 12: Clipping Substitution Placeholders, p. 321
  
HTH

Jean Jourdain

On Tuesday, October 5, 2021 at 3:33:05 AM UTC+2 listmei...@gmail.com wrote:

> On Oct 04, 2021, at 18:30, Sonic Purity  wrote:
>
> I cannot figure out how to use AppleScript to create a new HTML document 
> from an existing template file, as i easily do manually via ^⌘N then select 
> my template then type in the title in the Title field and tap Create.
>
> --
>
> Hey Sonic,
>
> That's easy enough if you already know how, but not so much if you don't.
>
> Recording is relatively useless – *except* for discovering the syntax for 
> some things that are really difficult to suss out.  A recorded script 
> very often takes a lot of editing to convert from a very verbose and 
> literal recording of actions to something that rationally makes sense to 
> user, computer, and task.
>
> Here's a sample template.  Note the underlined bold tags – these are 
> placeholders you can tab to in the open document.
>
> --
>
> 
> 
> 
> *<#TITLE#>*
> 
> 
> 
> *<#HTML_BODY#>*
> 
> 
>
> --
>
> You *can* use an AppleScript dialog to enter the title, but placeholders 
> are easier.
>
> This script uses the template-path defined with *property*
> * templateFilePath*.
>
> It also contains code to demonstrate the use of an embedded template 
> (commented-out).
>
> --
> Best Regards,
> Chris
>
> --
>
> 
> # Auth: Christopher Stone
> # dCre: 2021/10/04 20:07
> # dMod: 2021/10/04 20:07 
> # Appl: BBEdit
> # Task: Create a New HTML Document Using a Template File.
> # Libs: None
> # Osax: None
> # Tags: @Applescript, @Script, @ASObjC, @BBEdit, @Create, @HTML, 
> @Document, @Template
> 
> *use* AppleScript version "2.4" --» Yosemite or later
> *use* *framework* "Foundation"
> *use* *scripting additions*
> 
> *property* templateFilePath : "~/Documents/BBEdit 
> Documents/Templates/HTML_Template_01.txt"
> *property* defaultWindowBounds : {202, 45, 1238, 900} --» {X1, Y1, X2, 
> Y2} Upper-Left, Lower-Right
> 
>
> *set* templateFilePath *to* ((*current application's* NSString's 
> stringWithString:templateFilePath)'s stringByExpandingTildeInPath) *as* 
> *text*
> *set* templateText *to* *read* templateFilePath as «*class* utf8»
>
> *tell* *application* "BBEdit"
> # Create from a template FILE.
> *set* newDoc *to* *make* new *document* with properties {*text*
> :templateText}
>
> 
> # Create using embedded template TEXT in handler getTemplateText().
> # set newDoc to make new document with properties {text:my 
> getTemplateText()}
>
> 
> *tell* newDoc
> *if* *its* source language ≠ "HTML" *then* *set* *its* source 
> language *to* "HTML"
>
> 
> *tell* *its* *window*
> *if* *its* bounds ≠ defaultWindowBounds *then*
> *set* *its* bounds *to* defaultWindowBounds
> *end* *if*
> *end* *tell*
>
> 
> *end* *tell*
>
> 
> *end* *tell*
>
> 
> # Template Text
> 
> *on* getTemplateText()
> *return* *text* 2 *thru* -1 *of* "
> 
> 
> 
> <#TITLE#>
> 
> 
> 
> <#HTML_BODY#>
> 
> 
> "
> *end* getTemplateText
> 
>
>
>

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/dac3fbba-a8aa-4bbc-b3ff-39a9a34ad90dn%40googlegroups.com.


Re: Make new HTML document from template in AppleScript: How?

2021-10-04 Thread Christopher Stone
On Oct 04, 2021, at 18:30, Sonic Purity  wrote:
> I cannot figure out how to use AppleScript to create a new HTML document from 
> an existing template file, as i easily do manually via ^⌘N then select my 
> template then type in the title in the Title field and tap Create.

Hey Sonic,

That's easy enough if you already know how, but not so much if you don't.

Recording is relatively useless – except for discovering the syntax for some 
things that are really difficult to suss out.  A recorded script very often 
takes a lot of editing to convert from a very verbose and literal recording of 
actions to something that rationally makes sense to user, computer, and task.

Here's a sample template.  Note the underlined bold tags – these are 
placeholders you can tab to in the open document.





<#TITLE#>



<#HTML_BODY#>




You can use an AppleScript dialog to enter the title, but placeholders are 
easier.

This script uses the template-path defined with property templateFilePath.

It also contains code to demonstrate the use of an embedded template 
(commented-out).

--
Best Regards,
Chris



# Auth: Christopher Stone
# dCre: 2021/10/04 20:07
# dMod: 2021/10/04 20:07 
# Appl: BBEdit
# Task: Create a New HTML Document Using a Template File.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @BBEdit, @Create, @HTML, @Document, 
@Template

use AppleScript version "2.4" --» Yosemite or later
use framework "Foundation"
use scripting additions

property templateFilePath : "~/Documents/BBEdit 
Documents/Templates/HTML_Template_01.txt"
property defaultWindowBounds : {202, 45, 1238, 900} --» {X1, Y1, X2, Y2} 
Upper-Left, Lower-Right


set templateFilePath to ((current application's NSString's 
stringWithString:templateFilePath)'s stringByExpandingTildeInPath) as text
set templateText to read templateFilePath as «class utf8»

tell application "BBEdit"
# Create from a template FILE.
set newDoc to make new document with properties {text:templateText}

# Create using embedded template TEXT in handler getTemplateText().
# set newDoc to make new document with properties {text:my 
getTemplateText()}

tell newDoc
if its source language ≠ "HTML" then set its source language to "HTML"

tell its window
if its bounds ≠ defaultWindowBounds then
set its bounds to defaultWindowBounds
end if
end tell

end tell

end tell


# Template Text

on getTemplateText()
return text 2 thru -1 of "



<#TITLE#>



<#HTML_BODY#>


"
end getTemplateText



-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/623ADE4F-E213-4277-A714-3AA6FC838F44%40gmail.com.


Make new HTML document from template in AppleScript: How?

2021-10-04 Thread Sonic Purity
Greetings,
First, a big Thank You to everyone who’s participated in this group over 
the years. I’ve had at least half a dozen pressing questions answered via 
searching existing posts here, saving us all the trouble of me asking anew.

This one has me stumped, and searching here and generally on the WWW hasn't 
helped, nor has studying the BBEdit sample files.

I cannot figure out how to use AppleScript to create a new HTML document 
from an existing template file, as i easily do manually via ^⌘N then select 
my template then type in the title in the Title field and tap Create.

I did try Recording into a blank Script Editor window, performing the above 
steps: window remained totally empty, as though i’d done nothing.

How does one script this in AppleScript?

(BBEdit 11.6.8, macOS 10.12.6 Sierra, AppleScript 2.5 with Script Editor 
2.9)

~ Thanks ~

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/d4d7b65a-7565-4f15-adc7-9e2d10013219n%40googlegroups.com.