Skip to content

Commit ac89239

Browse files
authored
Merge pull request #9969 from quarto-dev/test-project-subfolder-support
2 parents 974eba9 + 099c4ee commit ac89239

File tree

17 files changed

+154
-110
lines changed

17 files changed

+154
-110
lines changed

news/changelog-1.5.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ All changes included in 1.5:
6464
- ([#8986](https://github.com/quarto-dev/quarto-cli/issues/8986)): Search: only build subfuse index when it's safe to do so.
6565
- ([#9356](https://github.com/quarto-dev/quarto-cli/issues/9356)): Don't process column classes for figures inside the About divs.
6666
- ([#9781](https://github.com/quarto-dev/quarto-cli/issues/9781)): Correctly hide elements from click event in collapsed margin sidebar.
67+
- Sidebar navigation item now correctly supports `rel` attribute.
68+
- `target` attribute for sidebar navigation items is now correctly inserted with HTML escapes.
6769

6870
## Book
6971

src/resources/projects/website/templates/navtools.ejs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const isWide = toolCount > 2; %>
4141
</ul>
4242
</div>
4343
<% } else { %>
44-
<a href="<%- tool.href %>" <%- tool.rel ? `rel="${tool.rel}"` : "" %> title="<%- tool.text %>" class="quarto-navigation-tool px-1" aria-label="<%- tool['aria-label'] || tool.text %>"<%= tool.target ? ` target="${tool.target}"` : "" %>><i class="bi bi-<%- tool.icon %>"></i></a>
44+
<a href="<%- tool.href %>" <%= tool.rel ? `rel="${tool.rel}"` : "" %> title="<%- tool.text %>" class="quarto-navigation-tool px-1" aria-label="<%- tool['aria-label'] || tool.text %>"<%= tool.target ? ` target="${tool.target}"` : "" %>><i class="bi bi-<%- tool.icon %>"></i></a>
4545
<% } %>
4646
<% }) %>
4747

src/resources/projects/website/templates/sidebaritem.ejs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<% if (item.href && item.text && !item.contents) { %>
44
<li class="sidebar-item">
55
<div class="sidebar-item-container">
6-
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%- item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
6+
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%= item.rel ? ` rel="${item.rel}"` : "" %><%= item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
77
</div>
88
</li>
99
<% } else if (item.contents && item.text) { %>
@@ -19,7 +19,7 @@
1919
<% if (item.contents.length > 0) { %>
2020
<div class="sidebar-item-container">
2121
<% if (item.href) { %>
22-
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%- item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
22+
<a href="<%- item.href %>" class="sidebar-item-text sidebar-link<%- item.active ? " active" : "" %>"<%= item.rel ? ` rel="${item.rel}"` : "" %><%= item.target ? ` target="${item.target}"` : "" %>><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
2323
<% } else { %>
2424
<a class="sidebar-item-text sidebar-link text-start<%- isCollapsed ? " collapsed" : "" %>" data-bs-toggle="collapse" data-bs-target="#<%- sectionId %>" role="navigation" aria-expanded="<%- isCollapsed ? "false" : "true" %>"><% partial('navicon.ejs', { item }) %> <span class="menu-text"><%= item.text %></span></a>
2525
<% } %>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.quarto/
2+
_site
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
project:
2+
type: website
3+
4+
website:
5+
title: "Sidebar-target"
6+
navbar:
7+
left:
8+
- href: index.qmd
9+
text: Home
10+
sidebar:
11+
contents:
12+
- href: https://quarto.org
13+
target: _blank
14+
rel: external
15+
text: Quarto website
16+
- text: PRERELEASE
17+
href: https://prerelease.quarto.org
18+
target: _blank
19+
rel: external
20+
contents:
21+
- href: https://prerelease.quarto.org
22+
target: _blank
23+
rel: external
24+
text: Quarto prerelease website
25+
26+
format: html
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
title: "Sidebar-target"
3+
_quarto:
4+
tests:
5+
html:
6+
ensureHtmlElements:
7+
-
8+
- 'nav#quarto-sidebar a[target="_blank"].sidebar-link'
9+
- 'nav#quarto-sidebar a[rel="external"].sidebar-link'
10+
-
11+
- "nav#quarto-sidebar a[target='\"_blank\"']"
12+
- "nav#quarto-sidebar a[rel='\"external\"']"
13+
- "nav#quarto-sidebar a.sidebar-link:not([rel])"
14+
---
15+
16+
This is a Quarto website.
17+
18+
To learn more about Quarto websites visit <https://quarto.org/docs/websites>.

tests/smoke/extensions/extension-render-project.test.ts

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,20 @@
44
* Copyright (C) 2020-2022 Posit Software, PBC
55
*/
66

7-
import { docs } from "../../utils.ts";
7+
import { docs, projectOutputForInput } from "../../utils.ts";
88

99
import { basename, dirname, extname, join, relative } from "../../../src/deno_ral/path.ts";
1010
import { ensureHtmlElements } from "../../verify.ts";
1111
import { testQuartoCmd } from "../../test.ts";
1212
import { noErrors } from "../../verify.ts";
1313
import { existsSync } from "fs/mod.ts";
1414

15-
const siteOutputForInput = (rootDir: string, input: string) => {
16-
const dir = join(rootDir, "_site");
17-
const stem = basename(input, extname(input));
18-
19-
const outputPath = join(
20-
dir,
21-
dirname(relative(rootDir, input)),
22-
`${stem}.html`,
23-
);
24-
const supportPath = join(dir, `site_libs`);
25-
26-
return {
27-
outputPath,
28-
supportPath,
29-
};
30-
};
31-
3215
const testRender = (
33-
rootDir: string,
3416
input: string,
3517
includeSelectors: string[],
3618
excludeSelectors: string[],
3719
) => {
38-
const output = siteOutputForInput(rootDir, input);
20+
const output = projectOutputForInput(input);
3921
const verifySel = ensureHtmlElements(
4022
output.outputPath,
4123
includeSelectors,
@@ -63,8 +45,7 @@ const rootDir = docs("extensions/project/");
6345

6446
// Render the home page and verify the output
6547
// contains the extension shortcodes and filter elements
66-
const rootInput = join(rootDir, "posts/welcome/index.qmd");
67-
testRender(rootDir, rootInput, [
48+
testRender(join(rootDir, "posts/welcome/index.qmd"), [
6849
"a.lightbox",
6950
"i.fa-solid.fa-anchor",
7051
"i.fa-solid.fa-bacteria",
@@ -74,7 +55,7 @@ testRender(rootDir, rootInput, [
7455
// Render the welcome page (subdirectory) and verify the output
7556
// contains the extension shortcodes and filter elements
7657
const subdirInput = join(rootDir, "posts/welcome/index.qmd");
77-
testRender(rootDir, subdirInput, [
58+
testRender(join(rootDir, "posts/welcome/index.qmd"), [
7859
"a.lightbox",
7960
"i.fa-solid.fa-anchor",
8061
"i.fa-solid.fa-bacteria",

tests/smoke/jats/render-manuscript.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@ import { ensureMECAValidates, ensureXmlValidatesWithXsd } from "../../verify.ts"
1111
import { testRender } from "../render/render.ts";
1212

1313
const xsdPath = docs(join("jats", "xsd", "JATS-Archiving-1-2-MathML2-DTD"));
14-
const projectOutDir = "_manuscript";
1514

1615
const testContext = undefined;
1716
const args = undefined;
1817

1918
// Test a basic manuscript render (this will include a sub-notebook which should
2019
// nonetheless validate)
2120
const input = docs(join("jats", "manuscript", "index.ipynb"));
22-
const output = outputForInput(input, "jats", projectOutDir);
21+
const output = outputForInput(input, "jats");
2322
const mecaOutput = join(dirname(output.outputPath), "index-meca.zip");
2423

2524
// Test the article and ensure that it validates
@@ -29,6 +28,5 @@ testRender(
2928
false,
3029
[ensureXmlValidatesWithXsd(output.outputPath, xsdPath), ensureMECAValidates(mecaOutput)],
3130
testContext,
32-
args,
33-
projectOutDir,
31+
args
3432
);

tests/smoke/project/common.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,15 @@ export async function cleanWorking() {
2121

2222
export type OutputVerify = (outputDir: string) => Verify[];
2323

24+
// This is similar to testSite.
25+
// It tests a project render, and allow to verify output directory assertions
2426
export const testProjectRender = (
2527
input: string,
2628
to: string,
27-
outputDir: string,
28-
outputVerify: OutputVerify
29+
outputVerify: OutputVerify = (_outDir: string): Verify[] => [],
2930
) => {
3031

31-
const output = outputForInput(input, to, outputDir);
32+
const output = outputForInput(input, to);
3233
const outDir = dirname(output.outputPath);
3334
const outVerify = outputVerify(outDir);
3435

tests/smoke/render/render-email.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ testRender(docs("email/email-attach.qmd"), "email", false, [fileExists(previewFi
3838
// Test an email render that has no subject line, this verifies that `rsc_email_subject` key is present and the value is an empty string
3939
testRender(docs("email/email-no-subject.qmd"), "email", false, [fileExists(previewFile), validJsonWithFields(jsonFile, {"rsc_email_subject": ""})], cleanupCtx);
4040

41-
// Render in a project with an output directory and confirm that everything ends up in the output directory
42-
testProjectRender(docs("email/project/email-attach.qmd"), "email", "_out", (outputDir: string) => {
41+
// Render in a project with an output directory set in _quarto.yml and confirm that everything ends up in the output directory
42+
testProjectRender(docs("email/project/email-attach.qmd"), "email", (outputDir: string) => {
4343
const verify: Verify[]= [];
4444
const json = join(outputDir, ".output_metadata.json");
4545
const preview = join(outputDir, "email-preview", "index.html");

0 commit comments

Comments
 (0)