Wrap a long identifier, and add the rendered page to the audit
A doc comment names an item by its full path, as in `NoiseTemperature::from_noise_figure_db`. A path has no space in it, so the column could shrink and the word could not, and the interface page of a crate scrolled sideways on a phone. The body of a document now breaks a word rather than overflow. The audit that renders every route now covers the whole interface: 744 combinations, being ninety-three routes in both languages and both themes at two widths, and it passes. It reports four things, which are the four ways a page has failed here before: a page that does not load, a page with almost no text, a page that scrolls sideways, and a formula that loses a letter or a digit. Two mistakes of the audit itself are fixed rather than worked around. It awaited a `Runtime.evaluate` that called `location.reload`. Such a call destroys its own execution context, so the reply never arrives, the promise never settles and the run hangs until the environment kills it. The preferences are now set once per language on a page that stays put, and each route is reached by an ordinary navigation. It gave the browser a function whose comment contained a backtick. The backtick closed the template literal that held the function, so the script did not parse at all. The formula comparison now treats a command name as notation, as it already did for the operators: \Delta draws a Greek letter and \sqrt a radical sign, so neither is drawn as the letters of its own name.
This commit is contained in:
parent
4957368aa3
commit
73b5f3de63
|
|
@ -863,6 +863,13 @@ button.ghost:hover:not(:disabled) {
|
||||||
|
|
||||||
.doc-body {
|
.doc-body {
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
/*
|
||||||
|
* A doc comment names items by their full path, as in
|
||||||
|
* `NoiseTemperature::from_noise_figure_db`, and a path has no space in it
|
||||||
|
* to break at. Left alone it makes the page scroll sideways on a phone,
|
||||||
|
* because the column can shrink but the word cannot.
|
||||||
|
*/
|
||||||
|
overflow-wrap: anywhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
.doc-body h1,
|
.doc-body h1,
|
||||||
|
|
|
||||||
|
|
@ -20,9 +20,12 @@
|
||||||
//! page, because the layout says what they said. A number or a name has no
|
//! page, because the layout says what they said. A number or a name has no
|
||||||
//! such excuse, so a missing one is a defect.
|
//! such excuse, so a missing one is a defect.
|
||||||
//!
|
//!
|
||||||
//! `sqrt` is notation of the same kind: it is drawn as the radical sign, so
|
//! A LaTeX command is notation of the same kind. `\sqrt` is drawn as the
|
||||||
//! its letters are gone by design and are not missed. Every other function
|
//! radical sign and `\Delta` as the Greek letter, so their letters are gone
|
||||||
//! name is drawn as its own letters, as in `sin` and `ln`.
|
//! by design and are not missed. A command whose name is its own glyph, such
|
||||||
|
//! as `\ln`, is drawn as those letters, so stripping every command only
|
||||||
|
//! makes this check less strict about a function name and never hides a lost
|
||||||
|
//! number.
|
||||||
|
|
||||||
use apsis_book::docs::document::Language;
|
use apsis_book::docs::document::Language;
|
||||||
|
|
||||||
|
|
@ -53,6 +56,28 @@ fn visible(html: &str) -> String {
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the text with the notation words removed.
|
||||||
|
///
|
||||||
|
/// A formula is written either as LaTeX, where a command is `\sqrt`, or as
|
||||||
|
/// plain notation, where the same root is the bare word `sqrt`. Both are
|
||||||
|
/// notation and neither is drawn as those letters.
|
||||||
|
fn strip_commands(source: &str) -> String {
|
||||||
|
let source = source.replace("sqrt", "");
|
||||||
|
let mut out = String::with_capacity(source.len());
|
||||||
|
let mut characters = source.chars().peekable();
|
||||||
|
while let Some(character) = characters.next() {
|
||||||
|
if character == '\\' {
|
||||||
|
// A command runs to the first character that is not a letter.
|
||||||
|
while characters.peek().is_some_and(|c| c.is_alphabetic()) {
|
||||||
|
characters.next();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push(character);
|
||||||
|
}
|
||||||
|
out
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the formula sources of one document, in order.
|
/// Returns the formula sources of one document, in order.
|
||||||
fn formula_blocks(html: &str) -> Vec<String> {
|
fn formula_blocks(html: &str) -> Vec<String> {
|
||||||
let mut found = Vec::new();
|
let mut found = Vec::new();
|
||||||
|
|
@ -80,10 +105,9 @@ fn every_formula_shows_every_character_it_was_written_with() {
|
||||||
checked += 1;
|
checked += 1;
|
||||||
// The source as written, without the spaces that only set it
|
// The source as written, without the spaces that only set it
|
||||||
// out on the page.
|
// out on the page.
|
||||||
// `sqrt` is drawn as the radical sign, so its letters are
|
// A command name is notation: what it draws is a sign or a
|
||||||
// notation of the same kind as the operators.
|
// Greek letter, not the letters of its name.
|
||||||
let written: String = source
|
let written: String = strip_commands(&source)
|
||||||
.replace("sqrt", "")
|
|
||||||
.chars()
|
.chars()
|
||||||
.filter(|c| c.is_alphanumeric())
|
.filter(|c| c.is_alphanumeric())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue