Creating complex web links

I can relate to that feeling.

OK, I’m back. Thanks for the continued exploring, guys. Just so you know, I have smart quotes permanently turned off in Scrivener, so it wasn;t anything to do with curly quotes

I’ve found out what’s happening when I enter the URL via the “Add Link” dialog in Scrivener:

  • If I set it to enter a web link, the prefix is http:// Entering the URL including the “target” bit it is fine and the box closes and the link is created.

BUT, I want https:// as the prefix!

  • If I set it to “No Prefix” and enter the whole address, (https://www. … target=“_blank”…) then when I press OK, it tells me that it is not a properly formed URL!

So There you are. I can either use no prefix and just enter the basic URL with the https:// prefix followed by @November_Sierra’s RegEx trick to add the rest in post compile; or I can use the web prefix http:// and do a find and replace post compile to make the prefixes https://

But I’ve developed other problems with it at the moment, so I’m turning in for the night and will sleep on it.

:smile:

Mark

1 Like

Actually…

There’s a third option. You could hand this task over to Joomla. Let the server modify links, depending on where they link to (e.g. external links open in a new window/tab, internal links don’t, or whatever). It’s at least worth checking out if such a functionality is already built in or available via an extension.

Something like that:

Disclaimer: Don’t install any extensions from unknown sources without inspecting their code. This is just an example.

This way you don’t have to try weird things in Scrivener, no post-processing, no RegExing, no worries. And if you change your mind later, there’s a central place to change all links at once.

2 Likes

By the way, I don’t know if it matters or not, but as I googled a bit on the topic, the few webpages I visited were actually writing the code line the other way around.

<a target="_blank" rel="noopener" href="http://www.whatever.co.uk/">

The order doesn’t matter (unless you have to process such tags in code).

EDIT:

“They may appear in any order.” Source: On SGML and HTML The latest spec doesn’t even bother to mention that, but it hasn’t changed. HTML Standard

OK guys, my final entry on this.

I’ve found that entering them as web links works, though, for some unfathomable reason, my 2015 5K iMac running MacOS 12.6.1 gives the http:// prefix, where my M1 Macbook Air running MacOS 13.0 gives the https:// prefix. But they are working; it’s only if, with the dialog set to no prefix, I try to enter the full URL including the https:// that Scrivener objects.

On other questions:

  • Last night, for some reason, the iMac wasn’t converting the links from Markdown links to HTML links … restarting the computer today seems to have sorted that out.

  • @November_Sierra, your suggestion of letting Joomla do the work was interesting. Sadly, the plugin requires Joomla 4 and we’re on Joomla 3.7 or something. But it gets more complicated. The first coder working for the developer who originally built this version of the website must have written some of his own routines rather than using standard Joomla ones, as I tried to update to a more recent version of Joomla, but it trashed the site and we had to restore from back-up. And the developer himself seems to have disappeared off the face of the earth; I know he had all sorts of problems during the pandemic.

I did set about trying to set up an instance of Joomla 4 on my iMac so that I could teach myself how to rebuild the site in that, but I couldn’t get it to install and life is too short.

Still, I’m basically good to go.

The classic.

I understand that your glass of Joomla is more than full right now (or forever), but after all of our testing yesterday… I’d strongly suggest not entering anything other than the URL itself in the address field. Add other attributes (target, rel, etc.) after compilation.

Back to square one.
. . . . . .

I’m sorry, but what can I say? I know “the workaround” doesn’t work, even if it appears to, it produces broken code. And micro-managing the behavior of links in Scrivener is the wrong place to start with.

No need to be sorry.

Yep.

1 Like

It is just one of these cases where it would have been nice if it worked, but no surprise that it didn’t.
Can’t quite complain.

I’ve been needing a haircut for weeks, and Scrivener still hasn’t done anything about it.

1 Like

And I thought this bug only occurs on my installations. :smile:

On a more serious note: @xiamenese Do you use any tools to automate certain workflows on your local machine?