Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly compare item and current window location which is URI encoded #11869

Merged
merged 3 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ All changes included in 1.7:

- ([#11701](https://github.com/quarto-dev/quarto-cli/issues/11701)): Wrap HTML emitted by EJS templates in `{=html}` blocks to avoid memory blowup issues with Pandoc's parser.

## Blog projects

- ([#11745](https://github.com/quarto-dev/quarto-cli/issues/11745)): Fix categories links under post title in post with url encoded path (e.g. with space or other special characters).

## Book projects

- ([#11520](https://github.com/quarto-dev/quarto-cli/issues/11520)): Book's cover image now escapes lightbox treatment, which was incorrectly applied to it when `lightbox: true` was set in the book's configuration.
Expand Down
5 changes: 3 additions & 2 deletions src/resources/formats/html/quarto.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,10 @@ window.document.addEventListener("DOMContentLoaded", function (_event) {
for (const listingPath of listingPaths) {
const pathWithoutLeadingSlash = listingPath.listing.substring(1);
for (const item of listingPath.items) {
const encodedItem = encodeURI(item);
if (
item === currentPagePath ||
item === currentPagePath + "index.html"
encodedItem === currentPagePath ||
encodedItem === currentPagePath + "index.html"
) {
// Resolve this path against the offset to be sure
// we already are using the correct path to the listing
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "testing post with space"
author: "Harlow Malloc"
date: "2024-12-28"
categories: [news, code, analysis]
image: "image.jpg"
---

This is a post folder name with space

```{r}
1 + 1
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "testing post with space"
author: "Harlow Malloc"
date: "2024-12-28"
categories: [news, code, analysis]
image: "image.jpg"
---

This is a post folder name with space

```{r}
1 + 1
```
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
title: "testing post with space"
author: "Harlow Malloc"
date: "2024-12-28"
categories: [news, code, analysis]
image: "image.jpg"
---

This is a post folder name with space

```{r}
1 + 1
```
25 changes: 13 additions & 12 deletions tests/integration/playwright/tests/blog-simple-blog.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,41 @@ Object.entries(testPages).forEach(([postDir, pageName]) => {
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeHidden();
});

const checkCategoryLink = async (page: Page, category: string, pageName: string) => {
const checkCategoryLink = async (page: Page, category: string, pageName: string, postTitle: string) => {
await page.getByText(category, { exact: true }).click();
await expect(page).toHaveURL(getUrl(`blog/simple-blog/_site/${pageName}#category=${encodeURIComponent(category)}`));
await expect(page.locator(`div.category[data-category="${btoa(encodeURIComponent(category))}"]`)).toHaveClass(/active/);
await expect(page.getByRole('link', { name: postTitle })).toBeVisible();
};

test(`All Categories links are clickable ${postDir} pages`,
async ({ page }) => {
// Checking link is working
await page.goto(`./blog/simple-blog/_site/${postDir}/welcome/`);
await checkCategoryLink(page, 'news', pageName);
await checkCategoryLink(page, 'news', pageName, 'Welcome To My Blog');
// Including for special characters
await page.getByRole('link', { name: 'Welcome To My Blog' }).click();
await checkCategoryLink(page, 'euros (€)', pageName);
await checkCategoryLink(page, 'euros (€)', pageName, 'Welcome To My Blog');
await page.getByRole('link', { name: 'Welcome To My Blog' }).click();
await checkCategoryLink(page, '免疫', pageName);
await checkCategoryLink(page, '免疫', pageName, 'Welcome To My Blog');
await page.goto(`./blog/simple-blog/_site/${postDir}/post-with-code/`);
await checkCategoryLink(page, "apos'trophe", pageName);
await checkCategoryLink(page, "apos'trophe", pageName, 'Post With Code');
// special check for when a page is not loaded from non root path
await page.goto(`./blog/simple-blog/_site/${postDir}/welcome/#img-lst`);
await checkCategoryLink(page, 'news', pageName);
await checkCategoryLink(page, 'news', pageName, 'Welcome To My Blog');
// special check for post with space in page name
await page.goto(`./blog/simple-blog/_site/${postDir}/post with space/`);
await checkCategoryLink(page, 'news', pageName, 'testing post with space');
});

if (pageName !== 'table.html') {
test(`Categories link on listing page works for ${pageName}`, async ({ page }) => {
await page.goto(`./blog/simple-blog/_site/${pageName}`);
await checkCategoryLink(page, 'apos\'trophe', pageName);
await expect(page.getByRole('link', { name: 'Post With Code' })).toBeVisible();
await checkCategoryLink(page, 'apos\'trophe', pageName, 'Post With Code');
await page.goto(`./blog/simple-blog/_site/${pageName}`);
await checkCategoryLink(page, 'euros (€)', pageName);
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
await checkCategoryLink(page, 'euros (€)', pageName, 'Welcome To My Blog');
await page.goto(`./blog/simple-blog/_site/${pageName}`);
await checkCategoryLink(page, '免疫', pageName);
await expect(page.getByRole('link', { name: 'Welcome To My Blog' })).toBeVisible();
await checkCategoryLink(page, '免疫', pageName, 'Welcome To My Blog');
});
}
});
Expand Down