diff options
author | Titus Wormer <tituswormer@gmail.com> | 2022-06-28 14:42:42 +0200 |
---|---|---|
committer | Titus Wormer <tituswormer@gmail.com> | 2022-06-28 15:15:01 +0200 |
commit | 769e7011d37a2ad54630aeebdb0b0163a0825f75 (patch) | |
tree | 43d4524f82b5206f684c7052e0522c9d96e7eb7b | |
parent | 63985f2735dadbf5bd207b2d8363b2c332fc1921 (diff) | |
download | markdown-rs-769e7011d37a2ad54630aeebdb0b0163a0825f75.tar.gz markdown-rs-769e7011d37a2ad54630aeebdb0b0163a0825f75.tar.bz2 markdown-rs-769e7011d37a2ad54630aeebdb0b0163a0825f75.zip |
Add docs for `RESOURCE_DESTINATION_BALANCE_MAX`
Diffstat (limited to '')
-rw-r--r-- | readme.md | 2 | ||||
-rw-r--r-- | src/constant.rs | 11 | ||||
-rw-r--r-- | src/construct/label_end.rs | 4 |
3 files changed, 11 insertions, 6 deletions
@@ -124,7 +124,6 @@ cargo doc --document-private-items #### Docs -- [ ] (1) `LINK_RESOURCE_DESTINATION_BALANCE_MAX` in constants - [ ] (1) `label_start_image`, `label_start_link` - [ ] (1) `label_end` - [ ] (1) `space_or_tab_one_line_ending` @@ -284,3 +283,4 @@ important. - [x] (1) Add docs for how references and definitions match - [x] (1) Add module docs to parser - [x] (1) Add improved docs in compiler +- [x] (1) Add docs for `RESOURCE_DESTINATION_BALANCE_MAX` diff --git a/src/constant.rs b/src/constant.rs index 5cb7826..fc74316 100644 --- a/src/constant.rs +++ b/src/constant.rs @@ -193,10 +193,15 @@ pub const HTML_RAW_SIZE_MAX: usize = 8; /// To safeguard performance, labels are capped at a large number: `999`. pub const LINK_REFERENCE_SIZE_MAX: usize = 999; -/// To do. +/// Maximum allowed unbalanced parens in destination. +/// +/// There can be many balanced parens, but if there are 33 opens that were not +/// yet closed, the destination does not parse. +/// `CommonMark` requires that at least 3 opening parens are allowed. /// See: <https://spec.commonmark.org/0.30/#link-destination>, -/// <https://github.com/remarkjs/react-markdown/issues/658#issuecomment-984345577>. -pub const LINK_RESOURCE_DESTINATION_BALANCE_MAX: usize = 32; +/// In practice, this is quite low, and several places instead cap it at 32. +/// See: <https://github.com/remarkjs/react-markdown/issues/658#issuecomment-984345577>. +pub const RESOURCE_DESTINATION_BALANCE_MAX: usize = 32; /// List of protocols allowed, when operating safely, as `href` on `a`. /// diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs index 6e8e476..a814302 100644 --- a/src/construct/label_end.rs +++ b/src/construct/label_end.rs @@ -1,6 +1,6 @@ //! To do -use crate::constant::LINK_RESOURCE_DESTINATION_BALANCE_MAX; +use crate::constant::RESOURCE_DESTINATION_BALANCE_MAX; use crate::construct::{ partial_destination::{start as destination, Options as DestinationOptions}, partial_label::{start as label, Options as LabelOptions}, @@ -436,7 +436,7 @@ fn resource_open(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { t, c, DestinationOptions { - limit: LINK_RESOURCE_DESTINATION_BALANCE_MAX, + limit: RESOURCE_DESTINATION_BALANCE_MAX, destination: TokenType::ResourceDestination, literal: TokenType::ResourceDestinationLiteral, marker: TokenType::ResourceDestinationLiteralMarker, |