retypeapp / retype

Retype is an ✨ ultra-high-performance✨ static site generator that builds a website based on simple text files.
https://retype.com
Other
1.02k stars 201 forks source link

Code block with title line highlighting issue inside 2nd tab onwards #541

Closed altworkz closed 1 year ago

altworkz commented 1 year ago

Attached the sample code for code block with title line highlighting issue. This issue is only encountered when there is a title in the code block, the highlighting on the second tab onwards works just fine if there's no title in the code block.

# Sample

+++ Tab 1

```js !#2 samplecode.json
export function calculateOffset(): number {
    const siteHeaderEl = document.getElementById("docs-site-header");
    const toolbarEl = document.getElementById("docs-toolbar");

    let offset = 20; // 20 is extra offset added before the focused element
    offset += siteHeaderEl ? siteHeaderEl.offsetHeight : 0;
    offset += toolbarEl ? toolbarEl.offsetHeight : 0;

    return -offset;
}
```

+++ Tab 2

```js !#2 samplecode.json
export function calculateOffset(): number {
    const siteHeaderEl = document.getElementById("docs-site-header");
    const toolbarEl = document.getElementById("docs-toolbar");

    let offset = 20; // 20 is extra offset added before the focused element
    offset += siteHeaderEl ? siteHeaderEl.offsetHeight : 0;
    offset += toolbarEl ? toolbarEl.offsetHeight : 0;

    return -offset;
}
```

+++ Tab 3

```js !#2 samplecode.json
export function calculateOffset(): number {
    const siteHeaderEl = document.getElementById("docs-site-header");
    const toolbarEl = document.getElementById("docs-toolbar");

    let offset = 20; // 20 is extra offset added before the focused element
    offset += siteHeaderEl ? siteHeaderEl.offsetHeight : 0;
    offset += toolbarEl ? toolbarEl.offsetHeight : 0;

    return -offset;
}
```

+++
geoffreymcgill commented 1 year ago

Looks like this issue has been fixed in Retype v3.0, which we hope to release soon.

I was able to reproduce in Retype v2.4.0 but not v3.0.0.

Here is a screen recording of your sample running in v3.0.0:

https://github.com/retypeapp/retype/assets/62210/f6a9f121-5d49-484c-a53f-6f704272d1e8

Hope this helps.