Skip to content

Commit

Permalink
Improve markdown loading support, more gracefully downgrade even if m…
Browse files Browse the repository at this point in the history
…arkdown render is not available
  • Loading branch information
utensil committed Aug 25, 2024
1 parent 924f091 commit ee6a99b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion assets/uts-ondemand.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const load_script = (src) => {

document.addEventListener('DOMContentLoaded', async () => {

const markdownit_tags = document.querySelectorAll('.markdownit-raw');
const markdownit_tags = document.querySelectorAll('.markdownit.lazy-loading');

if (markdownit_tags.length != 0) {
load_script('markdownit.js');
Expand Down
2 changes: 1 addition & 1 deletion assets/uts-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ figure {
text-align: center;
}

.markdownit-raw {
.markdownit.lazy-loading {
white-space: pre-wrap;
}

Expand Down
4 changes: 2 additions & 2 deletions bun/markdownit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import markdownit from 'markdown-it'

const md = markdownit({html: true});

const markdownit_tags = document.querySelectorAll('.markdownit-raw');
const markdownit_tags = document.querySelectorAll('.markdownit.lazy-loading');
console.log(markdownit_tags);
for (let i = 0; i < markdownit_tags.length; i++) {
const markdownit_tag = markdownit_tags[i];
const markdown_source = markdownit_tag.innerHTML;
console.log(markdown_source);
markdownit_tag.innerHTML = md.render(markdown_source);
markdownit_tag.classList.remove('markdownit-raw');
markdownit_tag.classList.remove('lazy-loading');
}
2 changes: 1 addition & 1 deletion trees/macros.tree
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ so the text size almost matches the size output by native forester code. This do
}

\def\md[body]{
\<html:div>[class]{markdownit-raw}{\body}
\<html:div>[class]{markdownit lazy-loading}{\body}
}

\def\loadjs[src]{
Expand Down
20 changes: 20 additions & 0 deletions trees/math-000P.tree
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,25 @@

\note{test tikz drawing: season 3}{

\md\verb>>>|

Here we only list some graphs worth adapting:

## pgfplots

- [Heteroskedasticity in a model of linear regression](https://pgfplots.net/heteroskedasticity-linear-regression/)
- [Spiral cone with projections and annotations](https://pgfplots.net/spiral-cone/)
- [Plotting several 2d functions in a 3d graph](https://pgfplots.net/2d-functions-in-3d/)
- [Lorentz system](https://pgfplots.net/lorentz-system/) (requires LuaLaTeX)
- [Moebius strip](https://pgfplots.net/moebius-strip/) (requires non-DVI drivers)

## TikZ

- [Izaak Neutelings](https://tikz.net/author/izaak/) has diagrams covering all areas of Physics, e.g. [vector analysis on manifolds](https://tikz.net/dynamics_moment_of_inertia_parrallel_axis/), [3D coordinate systems](https://tikz.net/axis3d/), [diagrams on different planes](https://tikz.net/decay_planes/)
- [Analysis](https://tikz.net/category/mathematics/analysis/) has many diagrams on analysis.
- [Bernouilli’s equation](https://tikz.net/fluid_dynamics_bernouilli/) has diagrams with proper shading of complicated smooth geometries.
- Some other interesting diagrams: [Helicoid](https://tikz.net/helicoid/), [Manifold mapping](https://tikz.net/manifold/), [topology](https://tikz.net/closed-string-topologies/), [Convolution Operator](https://tikz.net/conv2d/), [Fourier series & synthesis with projections](https://tikz.net/fourier_series/), [Tree with aligned matrix](https://tikz.net/tree-matrix/)

>>>

}

0 comments on commit ee6a99b

Please sign in to comment.