diff options
-rw-r--r-- | readme.md | 5 | ||||
-rw-r--r-- | src/construct/definition.rs | 1 | ||||
-rw-r--r-- | src/construct/partial_destination.rs | 7 |
3 files changed, 5 insertions, 8 deletions
@@ -82,10 +82,6 @@ cargo doc --document-private-items - [ ] (1) Add module docs to parser - [ ] (1) Add overview docs on how everything works -#### Refactor - -- [ ] (1) Configurable limit (destination) - #### Parse - [ ] (1) Parse initial and final whitespace of paragraphs (in text)\ @@ -237,6 +233,7 @@ cargo doc --document-private-items - [x] (1) Make text data, string data constructs (document in `construct/mod.rs`) - [x] (1) Configurable tokens (destination, label, title) +- [x] (1) Configurable limit (destination) ### Extensions diff --git a/src/construct/definition.rs b/src/construct/definition.rs index 69d8d9b..f8dc249 100644 --- a/src/construct/definition.rs +++ b/src/construct/definition.rs @@ -173,6 +173,7 @@ fn destination_before(tokenizer: &mut Tokenizer, code: Code) -> StateFnResult { t, c, DestinationOptions { + limit: usize::MAX, destination: TokenType::DefinitionDestination, literal: TokenType::DefinitionDestinationLiteral, marker: TokenType::DefinitionDestinationLiteralMarker, diff --git a/src/construct/partial_destination.rs b/src/construct/partial_destination.rs index 823ce99..b2ceeb8 100644 --- a/src/construct/partial_destination.rs +++ b/src/construct/partial_destination.rs @@ -57,6 +57,8 @@ pub struct Options { pub raw: TokenType, /// Token for a the string. pub string: TokenType, + /// Maximum unbalanced parens. + pub limit: usize, } /// State needed to parse destination. @@ -176,12 +178,9 @@ fn enclosed_escape(tokenizer: &mut Tokenizer, code: Code, info: Info) -> StateFn /// a|b /// ``` fn raw(tokenizer: &mut Tokenizer, code: Code, mut info: Info) -> StateFnResult { - // To do: configurable. - let limit = usize::MAX; - match code { Code::Char('(') => { - if info.balance >= limit { + if info.balance >= info.options.limit { (State::Nok, None) } else { tokenizer.consume(code); |