Strange behavior in imported tagged template

I am experiencing some strange behavior when importing a tagged template from another notebook (the same tagged template works fine when created within the notebook). This notebook: Untitled / Daniel Howe / Observable demonstrates the problem with a minimal example.

Any insight would be appreciated

When the like rsl = RiTa.template(md); is commented out, the imported rs works. It’s like the two versions don’t work together.

I don’t see that… When I comment the rsl call, I get the same behavior (see below). And I actually noticed the problem when using `rs ` alone, so I don’t think this is the issue (though I could be wrong).

Interesting.For me, the headings don’t work in either example. And even in the Rita Utilities notebook, the headings don’t work (see below).
image
I am using Chrome

1 Like

I tried to visit @dhowe/rita in Safari and it’s unable to load Rita due to a parsing error:

SyntaxError: Invalid regular expression: invalid group specifier name

I see the same thing as @Cobus in Chrome: it doesn’t render the headings on either of the two notebooks, and all the code behaves the same way.

Thanks much for everyone’s feedback. I think I’ve located in the issue in the library. The reason it was manifesting strangely was that different minor versions of the library were being loaded in the two examples.

Follow-ups:

  1. is there a way to specify ā€˜the newest version’ for a require ?
  2. is there a way to test (preferably in node) via the same `md` function as in the stdlib ? I’m currently using a tagged template I created from the `marked` lib on npm, but the behavior does not appear to be exactly the same

You can just say:
RiTa = require("rita")
which would get you the newest version.

That gets you the newest version at that moment. What I’m asking is if there is a way to keep in sync with the newest version…

I am not quite sure I understand the question then. It would load the newest version whenever you refresh your browser window (which would re-execute the ā€˜require’ call in the cell).

That doesn’t always seem to be the case. See below (directly after refresh):

Though this may relate to jsdelivr caching, which apparently can take up to 24 hrs

Ah, perhaps. This is what I get:
image

Was that a new notebook, or a an existing one that you refreshed? Because the jsdelivr cache has now refreshed with the new version and I still see previous versions in my notebooks after a page refresh:

OK, so I think this is due to cacheing in the browser. Require actually loads from unpkg, and if you read the cacheing behavior here: https://unpkg.com it seems like the best advice is actually to specify the version in the require, otherwise it may just use the browser cached version.

1 Like

It does? Afaik d3-require defaults to cdn.jsdelivr.net. Only Observable’s import() override defaults to unpkg.com (when used without a hostname).

Indeed, you are right! Sorry for the misinformation. Ignore what I said about require using unpkg!