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!