Skip to content

Commit e891ce9

Browse files
feat: Redirect old anchors to the current ones
1 parent 24ad23a commit e891ce9

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ import "./show-example.css";
33
import "./util.css";
44

55
import "./respec/mod.ts";
6+
import "./redirect-anchor.ts";

src/redirect-anchor.ts

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/**
2+
* Redirect old anchors (`id` attributes) to the current ones.
3+
*/
4+
5+
/** A map from old anchors to current anchors. */
6+
const REDIRECTS: Record<string, string> = {
7+
// Initial normalization
8+
"#x1-text-direction": "#direction",
9+
"#x1-1-writing-mode": "#writing-mode",
10+
"#vertical-writing-mode": "#vertical",
11+
"#x2-glyph-shaping-positioning": "#h-shaping",
12+
"#x2-1-fonts-selection": "#font-select",
13+
"#writing-chinese-without-configuring-any-font-leads-to-messy-font-fallback": "#font-fallback",
14+
"#wrong-monospace-font-fallback-for-chinese-in-raw-block": "#font-fallback-raw",
15+
"#wrong-font-fallback-for-chinese-in-math-equations": "#font-fallback-math",
16+
"#language-dependant-font-configuration": "#lang-font",
17+
"#size-per-font": "#per-font-size",
18+
"#unable-to-infer-the-writing-script-across-elements-making-locl-sometimes-ineffective-locl": "#across-element-script",
19+
"#x2-3-context-based-shaping-and-positioning": "#glyphs",
20+
"#fake-synthesized-bold": "#synthesized-bold",
21+
"#x2-6-case-other-character-transforms": "#transforms",
22+
"#x3-typographic-units": "#h-units",
23+
"#x3-1-characters-encoding": "#encoding",
24+
"#ideographic-variation-sequence-disappears-at-end-of-line": "#ivs-line-end",
25+
"#links-containing-non-ascii-characters-are-wrong-when-viewing-pdf-in-safari-ascii-safari-pdf": "#link-encoding",
26+
"#x3-2-grapheme-word-segmentation-selection": "#segmentation",
27+
"#x4-punctuation-inline-features": "#h-inline",
28+
"#x4-1-phrase-section-boundaries": "#punctuation-etc",
29+
"#quotation-marks-should-have-different-widths-for-chinese-and-western-text": "#quotation-mark-width",
30+
"#x4-3-emphasis-highlighting": "#emphasis",
31+
"#underline-breaks-when-mixing-chinese-and-western-text": "#underline-misalign",
32+
"#add-support-for-ruby-cjk-e-g-furigana-for-japanese": "#pinyin",
33+
"#x4-6-text-decoration-other-inline-features": "#text-decoration",
34+
"#x4-7-data-formats-numbers": "#data-formats",
35+
"#numbers-in-simplified-chinese": "#number-simplified",
36+
"#numbers-in-traditional-chinese": "#number-traditional",
37+
"#x5-line-and-paragraph-layout": "#h-lines-and-paragraphs",
38+
"#interpuncts-should-not-appear-at-line-start": "#interpunct-line-start",
39+
"#cjk-latin-glues-stretch-only-before-latin-characters": "#cjk-latin-stretch-before",
40+
"#strict-grid-aligned-in-both-horizontal-and-vertical-axes": "#strict-2d-grid",
41+
"#two-em-dashes-should-not-be-overhung": "#two-em-dash-overhung",
42+
"#customize-punctuation-overhang": "#customize-overhang",
43+
"#parenthetical-indication-punctuation-marks-at-the-start-of-paragraphs-are-not-adjusted-sometimes": "#paren-par-start",
44+
"#unexpected-indentation-after-figures-lists-and-block-equations": "#indent-after-block",
45+
"#even-inter-character-spacing": "#even-spacing",
46+
"#x5-3-text-spacing": "#spacing",
47+
"#cjk-latin-spacing-not-working-around-raw-raw": "#cjk-latin-around-raw",
48+
"#cjk-latin-spacing-not-working-around-inline-equations": "#cjk-latin-around-math",
49+
"#redundant-cjk-latin-space-at-manual-line-breaks": "#cjk-latin-manual-linebreak",
50+
"#punctuation-compression-is-interrupted-by-show-show": "#show-interrupt-punct",
51+
"#x5-4-baselines-line-height-etc": "#baselines",
52+
"#default-line-height-is-too-tight-for-chinese": "#default-line-height",
53+
"#box-is-not-aligned-if-text-bottom-edge-is-not-baseline-text-bottom-edge-box": "#box-align-bottom-edge",
54+
"#x5-5-lists-counters-etc": "#lists",
55+
"#list-and-enum-markers-are-not-aligned-with-the-baseline-of-the-item-s-contents-list-enum": "#list-enum-marker-align",
56+
"#too-wide-spacing-between-heading-numbering-and-title": "#heading-spacing-to-numbering",
57+
"#the-auto-hanging-indents-of-multiline-headings-are-inaccurate": "#heading-hanging-indent",
58+
"#x6-page-book-layout": "#h-pages",
59+
"#chinese-size-system-hao-system": "#zihao",
60+
"#directly-setting-the-width-of-the-type-area-instead-of-the-paper-width": "#type-area-width",
61+
"#x6-4-page-headers-footers-etc": "#headers-footers",
62+
"#x6-5-forms-user-interaction": "#interaction",
63+
"#x7-bibliography": "#bibliography",
64+
"#x7-1-citing": "#cite",
65+
"#citation-numbers-are-flying-over-their-brackets": "#cite-number-flying",
66+
"#compression-of-continuous-citation-numbers": "#cite-number-compress",
67+
"#superscript-and-non-superscript-forms-should-coexist": "#paren-cite",
68+
"#cite-with-page-numbers": "#cite-page-number",
69+
"#x7-2-bibliography-listing": "#bib-list",
70+
"#use-et-al-for-english-and-for-chinese-et-al": "#et-al-lang",
71+
"#institution-and-school-are-not-shown-institution-school": "#publisher-alias",
72+
"#discontinuous-page-numbers-are-displayed-incorrectly-missing-a-comma": "#cite-discontinuous-page",
73+
"#chinese-works-should-be-ordered-by-the-pinyin-or-strokes-of-the-authors-for-gb-7714-2015-author-date-gb-7714-2015-author-date": "#bib-order",
74+
"#gb-7714-2015-note-is-totally-broken-gb-7714-2015-note": "#bib-note",
75+
"#x7-3-bibliography-file": "#bib-file",
76+
"#standard-is-not-correctly-interpreted-standard": "#bib-standard-misc",
77+
"#failed-to-load-some-csl-styles-csl": "#csl-load",
78+
"#x8-other": "#h-other",
79+
"#x8-1-culture-specific-features": "#culture-specific",
80+
"#for-references-to-headings-the-supplement-should-not-be-put-before-the-number": "#ref-number-supplement",
81+
"#bilingual-figure-captions": "#bilingual-caption",
82+
"#x8-2-what-else": "#other",
83+
"#ignore-linebreaks-between-cjk-characters-in-source-code-cjk": "#ignore-linebreak",
84+
"#internationalize-warning-and-error-messages": "#i18n-diag",
85+
"#a-chinese-name-for-the-typst-project-typst": "#chinese-name",
86+
"#web-app-issues": "#webapp-issues",
87+
};
88+
89+
const old = window.location.hash;
90+
if (old in REDIRECTS) {
91+
window.location.hash = REDIRECTS[old];
92+
}

0 commit comments

Comments
 (0)