forked from quarto-dev/quarto-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Users will now be able to create `div`s and `span`s that exclude certain page elements from the search index.
- Loading branch information
1 parent
9e01d1c
commit c0d3ff3
Showing
14 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.quarto/ | ||
*.html | ||
*_files/ | ||
/_site_with_filter/ | ||
/_site_without_filter/ |
8 changes: 8 additions & 0 deletions
8
tests/docs/search/issue-11189/_extensions/remove-class/_extension.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
title: Remove-class | ||
author: Nick Vigilante | ||
version: 1.0.0 | ||
quarto-required: ">=99.9.0" | ||
contributes: | ||
filters: | ||
- remove-class.lua | ||
|
8 changes: 8 additions & 0 deletions
8
tests/docs/search/issue-11189/_extensions/remove-class/remove-class.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
-- Reformat all heading text | ||
function RemoveClass(el) | ||
class = "quarto-exclude-from-search-index" | ||
if el.classes:includes(class) then | ||
el.classes:remove(class) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project: | ||
output-dir: _site_with_filter | ||
post-render: | ||
- check-index-with-filter.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
project: | ||
output-dir: _site_without_filter | ||
post-render: | ||
- check-index-without-filter.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
project: | ||
type: website | ||
|
||
profile: | ||
default: without-filter | ||
|
||
website: | ||
title: "issue-11189" | ||
navbar: | ||
left: | ||
- href: index.qmd | ||
text: Home | ||
- about.qmd | ||
|
||
format: | ||
html: | ||
theme: cosmo | ||
css: styles.css | ||
toc: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "About" | ||
--- | ||
|
||
About this site | ||
|
||
::: {.quarto-exclude-from-search-index} | ||
|
||
Please don't find me. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const json = JSON.parse(Deno.readTextFileSync("_site_with_filter/search.json")); | ||
|
||
const obj = Object.fromEntries(json.map((x: any) => [x.objectID, x])); | ||
|
||
const file = "index.html"; | ||
|
||
if (obj[file].text.match("Please find me.") === null) { | ||
throw new Error("could not find text that should be shown in " + file); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
const json = JSON.parse(Deno.readTextFileSync("_site_without_filter/search.json")); | ||
|
||
const obj = Object.fromEntries(json.map((x: any) => [x.objectID, x])); | ||
|
||
const file = "about.html"; | ||
|
||
if (obj[file].text.match("Please don't find me.") !== null) { | ||
throw new Error("found text that should be hidden in " + file); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "issue-11189" | ||
filters: | ||
- _extensions/remove-class/remove-class.lua | ||
--- | ||
|
||
This is a Quarto website. | ||
|
||
To learn more about Quarto websites visit <https://quarto.org/docs/websites>. | ||
|
||
::: {.quarto-exclude-from-search-index} | ||
|
||
Please find me. | ||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/* css styles */ |
40 changes: 40 additions & 0 deletions
40
tests/smoke/search/validate-search-index-exclusion.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { testQuartoCmd } from "../../test.ts"; | ||
import { fileExists, noErrorsOrWarnings } from "../../verify.ts"; | ||
|
||
import { existsSync } from "../../../src/deno_ral/fs.ts"; | ||
import { join } from "../../../src/deno_ral/path.ts"; | ||
import { docs } from "../../utils.ts"; | ||
|
||
// Test a simple site | ||
const input = docs("search/issue-11189"); | ||
const withFilterProfile = "--profile with-filter" | ||
|
||
testQuartoCmd( | ||
"render", | ||
[input], | ||
[noErrorsOrWarnings], | ||
{ | ||
name: "Test search exclusions without filter", | ||
teardown: async () => { | ||
const siteDir = join(input, "_site_without_filter"); | ||
if (existsSync(siteDir)) { | ||
await Deno.remove(siteDir, { recursive: true }); | ||
} | ||
}, | ||
}, | ||
); | ||
|
||
testQuartoCmd( | ||
"render", | ||
[withFilterProfile, input], | ||
[noErrorsOrWarnings], | ||
{ | ||
name: "Test search exclusions with filter", | ||
teardown: async () => { | ||
const siteDir = join(input, "_site_with_filter"); | ||
if (existsSync(siteDir)) { | ||
await Deno.remove(siteDir, { recursive: true }); | ||
} | ||
}, | ||
}, | ||
); |