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: Beachball Won't Stop

2021-10-05 Thread Rich Siegel

On 5 Oct 2021, at 17:13, RPR wrote:


Just lost the last two hours recreating links & changing permissions.
Nothing.
Something may have changed that day but it soon reverted to its 
previous

behaviour.


In that case, then, I would recommend replying to Tech Support on the 
original case number (include "Case 415964" in the subject line).


If you have the previous email history at hand, the "sample" command 
provided therein will yield useful data. Including it (as a Zipped 
attachment) with your inquiry will save a request/response cycle.


Thanks,

R.

--
Rich Siegel Bare Bones Software, Inc.
  

Someday I'll look back on all this and laugh... until they sedate me.

--
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/D5C7752A-0ADB-47A8-816D-F47547800DD3%40barebones.com.


Re: Beachball Won't Stop

2021-10-05 Thread RPR
Just lost the last two hours recreating links & changing permissions. 
Nothing.
Something may have changed that day but it soon reverted to its previous 
behaviour.

BBEdit 13.5.7 now on BigSur.

On Tuesday, October 5, 2021 at 5:04:48 PM UTC-4 sie...@barebones.com wrote:

> On 5 Oct 2021, at 16:58, RPR wrote:
>
> > Rich ...
> >
> > (Case 415964) BBEdit Hangs
>
> Found it, thanks.
>
> As part of the email exchange in the case, you wrote (16 December 2020):
>
> > In the meantime I did the obvious and recreated the link and now it 
> > works. I suppose something at the OS level.
>
> So I would recommend doing that again, and see if the solution works 
> again.
>
> R.
>
> -- 
> Rich Siegel Bare Bones Software, Inc.
>  
>
> Someday I'll look back on all this and laugh... until they sedate me.
>

-- 
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/9ef20843-52be-4cc7-adbb-f5cc8dd03baan%40googlegroups.com.


Re: Beachball Won't Stop

2021-10-05 Thread Rich Siegel

On 5 Oct 2021, at 16:58, RPR wrote:


Rich ...

(Case 415964) BBEdit Hangs


Found it, thanks.

As part of the email exchange in the case, you wrote (16 December 2020):

	In the meantime I did the obvious and recreated the link and now it 
works. I suppose something at the OS level.


So I would recommend doing that again, and see if the solution works 
again.


R.

--
Rich Siegel Bare Bones Software, Inc.
  

Someday I'll look back on all this and laugh... until they sedate me.

--
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/D1BDFC20-CAEF-4548-8A51-C764945363C5%40barebones.com.


Re: Beachball Won't Stop

2021-10-05 Thread RPR
Rich ...

(Case 415964) BBEdit Hangs

On Tuesday, October 5, 2021 at 4:47:33 PM UTC-4 sie...@barebones.com wrote:

> On 5 Oct 2021, at 16:33, RPR wrote:
>
> > I've been having a problem since upgrading to Catalina.
> > Some of the files in my working directory are links of the type file1 
> > ->
> > ../dir2/testfile.. Whenever I try to open file1, BBEdit goes into a 
> > spin
> > and I have to force quit. I never had this problem before Catalina.
>
> I've never heard of it happening. Doesn't mean it's impossible, of 
> course.
>
> > I've run this by support but didn't get an answer. I wonder if anyone 
> > else
> > has seen this.
>
> Didn't get an *answer*, or didn't get an *response*? Those things are 
> different.
>
> I couldn't find a support case based on your email address, so if you 
> have a support case number, please provide it and I'll be happy to look 
> that up.
>
> If Tech Support received an email from you with a complaint like the 
> above, they certainly would have asked for additional details and likely 
> the output of a `sample` command.
>
> On the other hand if you meant "Apple support", I can totally imagine 
> getting neither a response nor an answer from *them*.
>
> R.
>
> -- 
> Rich Siegel Bare Bones Software, Inc.
>  
>
> Someday I'll look back on all this and laugh... until they sedate me.
>

-- 
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/39ba4ce6-a98c-47fa-bf64-3c82bd74818bn%40googlegroups.com.


Re: Beachball Won't Stop

2021-10-05 Thread Rich Siegel

On 5 Oct 2021, at 16:33, RPR wrote:


I've been having a problem since upgrading to Catalina.
Some of the files in my working directory are links of the type file1 
->
../dir2/testfile.. Whenever I try to open file1, BBEdit goes into a 
spin

and I have to force quit. I never had this problem before Catalina.


I've never heard of it happening. Doesn't mean it's impossible, of 
course.


I've run this by support but didn't get an answer. I wonder if anyone 
else

has seen this.


Didn't get an *answer*, or didn't get an *response*? Those things are 
different.


I couldn't find a support case based on your email address, so if you 
have a support case number, please provide it and I'll be happy to look 
that up.


If Tech Support received an email from you with a complaint like the 
above, they certainly would have asked for additional details and likely 
the output of a `sample` command.


On the other hand if you meant "Apple support", I can totally imagine 
getting neither a response nor an answer from *them*.


R.

--
Rich Siegel Bare Bones Software, Inc.
  

Someday I'll look back on all this and laugh... until they sedate me.

--
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/9F02A911-B80D-4211-94E4-A7175F4F5B07%40barebones.com.


Beachball Won't Stop

2021-10-05 Thread RPR
I've been having a problem since upgrading to Catalina. 
Some of the files in my working directory are links of the type file1 -> 
../dir2/testfile.. Whenever I try to open file1, BBEdit goes into a spin 
and I have to force quit. I never had this problem before Catalina.

I've run this by support but didn't get an answer. I wonder if anyone else 
has seen this.

-- 
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/8be3bf6b-5b34-4c62-9435-f476b25d3f4dn%40googlegroups.com.


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.