diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-12-02 14:19:52 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2024-12-04 10:12:07 +0100 |
| commit | e0122a5b509d151b7e0197d37a120fd965a055d5 (patch) | |
| tree | 1045c37c53dc2e08fedc8802cdfec1b244e10dd0 /crates/typst-library/src/engine.rs | |
| parent | 885c7d96eea73f478faea9877f0dbc40c00b0d7b (diff) | |
Add HTML export format
Diffstat (limited to 'crates/typst-library/src/engine.rs')
| -rw-r--r-- | crates/typst-library/src/engine.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/crates/typst-library/src/engine.rs b/crates/typst-library/src/engine.rs index e532172e..cd25ec48 100644 --- a/crates/typst-library/src/engine.rs +++ b/crates/typst-library/src/engine.rs @@ -301,6 +301,9 @@ impl Route<'_> { /// The maximum layout nesting depth. const MAX_LAYOUT_DEPTH: usize = 72; + /// The maximum HTML nesting depth. + const MAX_HTML_DEPTH: usize = 72; + /// The maximum function call nesting depth. const MAX_CALL_DEPTH: usize = 80; @@ -326,6 +329,17 @@ impl Route<'_> { Ok(()) } + /// Ensures that we are within the maximum HTML depth. + pub fn check_html_depth(&self) -> HintedStrResult<()> { + if !self.within(Route::MAX_HTML_DEPTH) { + bail!( + "maximum HTML depth exceeded"; + hint: "try to reduce the amount of nesting of your HTML", + ); + } + Ok(()) + } + /// Ensures that we are within the maximum function call depth. pub fn check_call_depth(&self) -> StrResult<()> { if !self.within(Route::MAX_CALL_DEPTH) { |
