simonw / til

Today I Learned
https://til.simonwillison.net
Apache License 2.0
1.02k stars 81 forks source link

GitHub Markdown API changed and broke my links #84

Closed simonw closed 9 months ago

simonw commented 9 months ago

Following:

The output of the GitHub Markdown API I am using changed and now:

https://til.simonwillison.net/sqlite/sqlite-tg

CleanShot 2023-09-25 at 13 10 06@2x

But it doesn't quite work - #installation does not resolve to user-content-installation:

<h2 id="user-content-installation">
  <a class="heading-link" href="#installation">Installation
    <span aria-hidden="true" class="octicon octicon-link"></span>
  </a>
</h2>
simonw commented 9 months ago

On older pages rendered before that change it looks like this: https://til.simonwillison.net/sqlite/cr-sqlite-macos

CleanShot 2023-09-25 at 13 11 26@2x
simonw commented 9 months ago

Short-term fix: JavaScript. Longer-term fix: rewrite the HTML that comes back from the API before saving it in the database.

simonw commented 9 months ago

Current JavaScript:

https://github.com/simonw/til/blob/0f7967e82e997c1c3762e29bb6d963eeafc9f650/templates/pages/%7Btopic%7D/%7Bslug%7D.html#L50-L68

simonw commented 9 months ago

Previous HTML looks like this:

<h2>
  <a id="user-content-how-that-all-works" class="anchor" aria-hidden="true" href="#how-that-all-works">
  <span aria-hidden="true" class="octicon octicon-link"></span>
  </a>How that all works
</h2>
simonw commented 9 months ago

I'm almost happy with this workaround: https://til.simonwillison.net/sqlite/sqlite-tg

CleanShot 2023-09-25 at 13 20 16@2x

But... https://til.simonwillison.net/sqlite/sqlite-tg#trying-it-out is the link it generates, which works with JS enabled but isn't the actual ID in the page. I'll fix that.

simonw commented 9 months ago

I'm happy with this.