Skip to content

Commit 1db62c7

Browse files
delete history
0 parents  commit 1db62c7

1,444 files changed

Lines changed: 23593 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { defineConfig } from 'vitepress'
2+
import { tabsMarkdownPlugin } from 'vitepress-plugin-tabs'
3+
import mathjax3 from "markdown-it-mathjax3";
4+
import footnote from "markdown-it-footnote";
5+
6+
// https://vitepress.dev/reference/site-config
7+
export default defineConfig({
8+
base: '/SymbolicAnalysis.jl/dev/',// TODO: replace this in makedocs!
9+
title: 'SymbolicAnalysis.jl',
10+
description: "A VitePress Site",
11+
lastUpdated: true,
12+
cleanUrls: true,
13+
outDir: '../1', // This is required for MarkdownVitepress to work correctly...
14+
head: [['link', { rel: 'icon', href: 'REPLACE_ME_DOCUMENTER_VITEPRESS_FAVICON' }]],
15+
ignoreDeadLinks: true,
16+
17+
markdown: {
18+
math: true,
19+
config(md) {
20+
md.use(tabsMarkdownPlugin),
21+
md.use(mathjax3),
22+
md.use(footnote)
23+
},
24+
theme: {
25+
light: "github-light",
26+
dark: "github-dark"}
27+
},
28+
themeConfig: {
29+
outline: 'deep',
30+
31+
search: {
32+
provider: 'local',
33+
options: {
34+
detailedView: true
35+
}
36+
},
37+
nav: [
38+
{ text: 'Home', link: '/index' },
39+
{ text: 'Examples', link: '/examples' },
40+
{ text: 'Atoms', link: '/atoms' },
41+
{ text: 'Special Functions', link: '/functions' }
42+
]
43+
,
44+
sidebar: [
45+
{ text: 'Home', link: '/index' },
46+
{ text: 'Examples', link: '/examples' },
47+
{ text: 'Atoms', link: '/atoms' },
48+
{ text: 'Special Functions', link: '/functions' }
49+
]
50+
,
51+
editLink: { pattern: "https://https://github.com/SciML/SymbolicAnalysis.jl/edit/main/docs/src/:path" },
52+
socialLinks: [
53+
{ icon: 'github', link: 'https://github.com/SciML/SymbolicAnalysis.jl' }
54+
],
55+
footer: {
56+
message: 'Made with <a href="https://luxdl.github.io/DocumenterVitepress.jl/dev/" target="_blank"><strong>DocumenterVitepress.jl</strong></a><br>',
57+
copyright: `© Copyright ${new Date().getUTCFullYear()}.`
58+
}
59+
}
60+
})
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type { ShikiTransformer } from "shiki"
2+
3+
type PromptKind = "julia" | "pkg" | null
4+
5+
export function juliaReplTransformer(): ShikiTransformer {
6+
let promptInfoByLine: Array<{ len: number; kind: PromptKind }> = []
7+
let isJuliaBlock = false
8+
const rules: Array<{ kind: PromptKind; re: RegExp }> = [
9+
{ kind: "julia", re: /^julia>/ },
10+
{ kind: "pkg", re: /^(\([^)]*\)\s*)?pkg>/ }, // handles (@v1.9) pkg>
11+
]
12+
13+
function classify(line: string): { len: number; kind: PromptKind } {
14+
for (const r of rules) {
15+
const m = line.match(r.re)
16+
if (m) return { len: m[0].length, kind: r.kind }
17+
}
18+
19+
return { len: 0, kind: null }
20+
}
21+
22+
return {
23+
name: "julia-repl-prompts",
24+
25+
preprocess(code, options) {
26+
isJuliaBlock = options.lang === "julia"
27+
return code
28+
},
29+
30+
tokens(tokens) {
31+
if (!isJuliaBlock) {
32+
promptInfoByLine = []
33+
return
34+
}
35+
36+
promptInfoByLine = tokens.map((lineTokens) => {
37+
const line = lineTokens.map((t) => t.content).join("")
38+
return classify(line)
39+
})
40+
},
41+
42+
span(node, line, col) {
43+
if (!isJuliaBlock) return
44+
45+
const info = promptInfoByLine[line - 1]
46+
if (!info || !info.kind || info.len <= 0) return
47+
48+
if (col < info.len) {
49+
this.addClassToHast(node, "repl-prompt")
50+
this.addClassToHast(node, `repl-prompt-${info.kind}`)
51+
}
52+
},
53+
}
54+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// adapter from https://github.com/orgs/vuepress-theme-hope/discussions/5178#discussioncomment-15642629
2+
// mathjax-plugin.ts
3+
// @ts-ignore
4+
import MathJax from '@mathjax/src'
5+
import type { Plugin as VitePlugin } from 'vite'
6+
import type MarkdownIt from 'markdown-it'
7+
import { tex as mdTex } from '@mdit/plugin-tex'
8+
9+
const mathjaxStyleModuleID = 'virtual:mathjax-styles.css'
10+
11+
interface MathJaxOptions {
12+
font?: string
13+
}
14+
15+
async function initializeMathJax(options: MathJaxOptions = {}) {
16+
const font = options.font || 'mathjax-newcm'
17+
18+
const config: any = {
19+
loader: {
20+
load: [
21+
'input/tex',
22+
'output/svg',
23+
'[tex]/boldsymbol',
24+
'[tex]/braket',
25+
'[tex]/mathtools',
26+
],
27+
paths: { mathjax: '@mathjax/src/bundle' },
28+
},
29+
tex: {
30+
tags: 'ams',
31+
packages: {
32+
'[+]': ['boldsymbol', 'braket', 'mathtools'],
33+
},
34+
},
35+
output: {
36+
font,
37+
displayOverflow: 'linebreak',
38+
mtextInheritFont: true,
39+
},
40+
svg: {
41+
fontCache: 'none', // critical: avoids async font loading
42+
},
43+
}
44+
45+
await MathJax.init(config)
46+
await MathJax.startup.document.outputJax.font.loadDynamicFiles()
47+
}
48+
49+
export function mathjaxPlugin(options: MathJaxOptions = {}) {
50+
let adaptor: any
51+
let initialized = false
52+
53+
async function ensureInitialized() {
54+
if (!initialized) {
55+
await initializeMathJax(options)
56+
adaptor = MathJax.startup.adaptor
57+
initialized = true
58+
}
59+
}
60+
61+
function renderMath(content: string, displayMode: boolean): string {
62+
if (!initialized) {
63+
throw new Error('MathJax not initialized')
64+
}
65+
66+
const node = MathJax.tex2svg(content, { display: displayMode })
67+
68+
// Prevent Vue from touching MathJax output
69+
adaptor.setAttribute(node, 'v-pre', '')
70+
71+
let html = adaptor.outerHTML(node)
72+
73+
// Preserve spaces inside mjx-break (SVG only)
74+
html = html.replace(
75+
/<mjx-break(.*?)>(.*?)<\/mjx-break>/g,
76+
(_: string, attr: string, inner: string) =>
77+
`<mjx-break${attr}>${inner.replace(/ /g, '&nbsp;')}</mjx-break>`,
78+
)
79+
80+
// Wrap only display equations (not inline math)
81+
html = html.replace(
82+
/(<mjx-container[^>]*display="true"[^>]*>)([\s\S]*?)(<\/mjx-container>)/,
83+
'<div class="mjx-scroll-wrapper">$1$2$3</div>'
84+
)
85+
86+
return html
87+
}
88+
89+
function getMathJaxStyles(): string {
90+
return initialized
91+
? adaptor.textContent(MathJax.svgStylesheet()) || ''
92+
: ''
93+
}
94+
95+
function resetMathJax(): void {
96+
if (!initialized) return
97+
MathJax.texReset()
98+
MathJax.typesetClear()
99+
}
100+
101+
function viteMathJax(): VitePlugin {
102+
const virtualModuleID = '\0' + mathjaxStyleModuleID
103+
104+
return {
105+
name: 'mathjax-styles',
106+
107+
resolveId(id) {
108+
if (id === mathjaxStyleModuleID) {
109+
return virtualModuleID
110+
}
111+
},
112+
113+
async load(id) {
114+
if (id === virtualModuleID) {
115+
await ensureInitialized()
116+
return getMathJaxStyles()
117+
}
118+
},
119+
}
120+
}
121+
122+
function mdMathJax(md: MarkdownIt): void {
123+
mdTex(md, {
124+
render: renderMath,
125+
})
126+
127+
const orig = md.render
128+
md.render = function (...args) {
129+
resetMathJax()
130+
return orig.apply(this, args)
131+
}
132+
}
133+
134+
const init = ensureInitialized()
135+
136+
return {
137+
vitePlugin: viteMathJax(),
138+
markdownConfig: mdMathJax,
139+
styleModuleID: mathjaxStyleModuleID,
140+
init,
141+
}
142+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
.jldocstring.custom-block {
2+
border: 1px solid var(--vp-c-gray-2);
3+
color: var(--vp-c-text-1);
4+
overflow: hidden;
5+
}
6+
7+
.jldocstring.custom-block summary {
8+
font-weight: 700;
9+
cursor: pointer;
10+
user-select: none;
11+
margin: 0 0 8px;
12+
}
13+
.jldocstring.custom-block summary a {
14+
pointer-events: none;
15+
text-decoration: none;
16+
}
17+
18+
.jldocstring.custom-block .source-link {
19+
border: 1px solid var(--vp-c-gray-2);
20+
border-radius: 4px;
21+
text-decoration: none;
22+
background-color: #414040;
23+
float: right;
24+
opacity: 0;
25+
visibility: hidden;
26+
transform: translateY(-5px);
27+
transition: all 0.5s cubic-bezier(0.25, 0.1, 0.25, 1);
28+
}
29+
30+
.jldocstring.custom-block .source-link a {
31+
text-decoration: none;
32+
color: #e5e5e5;
33+
}
34+
35+
.jldocstring.custom-block .source-link a:hover {
36+
text-decoration: underline;
37+
}
38+
39+
.jldocstring.custom-block:hover .source-link {
40+
opacity: 1;
41+
visibility: visible;
42+
transform: translateY(0);
43+
}
44+
45+
@media (max-width: 768px) {
46+
.jldocstring.custom-block .source-link {
47+
opacity: 1;
48+
visibility: visible;
49+
transform: translateY(0);
50+
}
51+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// .vitepress/theme/index.ts
2+
import { h } from 'vue'
3+
import type { Theme } from 'vitepress'
4+
import DefaultTheme from 'vitepress/theme'
5+
6+
import { enhanceAppWithTabs } from 'vitepress-plugin-tabs/client'
7+
import './style.css'
8+
9+
export default {
10+
extends: DefaultTheme,
11+
Layout() {
12+
return h(DefaultTheme.Layout, null, {
13+
// https://vitepress.dev/guide/extending-default-theme#layout-slots
14+
})
15+
},
16+
enhanceApp({ app, router, siteData }) {
17+
enhanceAppWithTabs(app)
18+
}
19+
} satisfies Theme

0 commit comments

Comments
 (0)