From 5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Fri, 19 Aug 2022 17:09:16 +0200 Subject: Refactor to move more things to `util/` --- src/construct/autolink.rs | 6 +++--- src/construct/block_quote.rs | 2 +- src/construct/character_reference.rs | 14 ++++++++------ src/construct/code_fenced.rs | 6 ++++-- src/construct/code_indented.rs | 2 +- src/construct/frontmatter.rs | 2 +- src/construct/heading_atx.rs | 2 +- src/construct/heading_setext.rs | 3 +-- src/construct/html_flow.rs | 12 ++++++------ src/construct/html_text.rs | 2 +- src/construct/label_end.rs | 2 +- src/construct/list_item.rs | 2 +- src/construct/partial_label.rs | 4 ++-- src/construct/partial_whitespace.rs | 8 +++++--- src/construct/thematic_break.rs | 2 +- 15 files changed, 37 insertions(+), 32 deletions(-) (limited to 'src/construct') diff --git a/src/construct/autolink.rs b/src/construct/autolink.rs index b25dc32..4ecd580 100644 --- a/src/construct/autolink.rs +++ b/src/construct/autolink.rs @@ -116,15 +116,15 @@ //! [definition]: crate::construct::definition //! [label_start_link]: crate::construct::label_start_link //! [label_end]: crate::construct::label_end -//! [autolink_scheme_size_max]: crate::constant::AUTOLINK_SCHEME_SIZE_MAX -//! [autolink_domain_size_max]: crate::constant::AUTOLINK_DOMAIN_SIZE_MAX +//! [autolink_scheme_size_max]: crate::util::constant::AUTOLINK_SCHEME_SIZE_MAX +//! [autolink_domain_size_max]: crate::util::constant::AUTOLINK_DOMAIN_SIZE_MAX //! [sanitize_uri]: crate::util::sanitize_uri //! [html_a]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element -use crate::constant::{AUTOLINK_DOMAIN_SIZE_MAX, AUTOLINK_SCHEME_SIZE_MAX}; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +use crate::util::constant::{AUTOLINK_DOMAIN_SIZE_MAX, AUTOLINK_SCHEME_SIZE_MAX}; /// Start of autolink. /// diff --git a/src/construct/block_quote.rs b/src/construct/block_quote.rs index 8d7e227..039c839 100644 --- a/src/construct/block_quote.rs +++ b/src/construct/block_quote.rs @@ -46,11 +46,11 @@ //! [html-blockquote]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-blockquote-element //! [commonmark-block]: https://spec.commonmark.org/0.30/#phase-1-block-structure -use crate::constant::TAB_SIZE; use crate::construct::partial_space_or_tab::space_or_tab_min_max; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +use crate::util::constant::TAB_SIZE; /// Start of block quote. /// diff --git a/src/construct/character_reference.rs b/src/construct/character_reference.rs index 3bdc636..4669836 100644 --- a/src/construct/character_reference.rs +++ b/src/construct/character_reference.rs @@ -65,17 +65,19 @@ //! [text]: crate::construct::text //! [character_escape]: crate::construct::character_reference //! [decode_numeric]: crate::util::decode_character_reference::decode_numeric -//! [character_references]: crate::constant::CHARACTER_REFERENCES +//! [character_references]: crate::util::constant::CHARACTER_REFERENCES //! [html]: https://html.spec.whatwg.org/multipage/parsing.html#character-reference-state -use crate::constant::{ - CHARACTER_REFERENCES, CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, - CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, CHARACTER_REFERENCE_NAMED_SIZE_MAX, -}; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; -use crate::util::slice::Slice; +use crate::util::{ + constant::{ + CHARACTER_REFERENCES, CHARACTER_REFERENCE_DECIMAL_SIZE_MAX, + CHARACTER_REFERENCE_HEXADECIMAL_SIZE_MAX, CHARACTER_REFERENCE_NAMED_SIZE_MAX, + }, + slice::Slice, +}; /// Start of character reference. /// diff --git a/src/construct/code_fenced.rs b/src/construct/code_fenced.rs index 748e38f..bfd15dc 100644 --- a/src/construct/code_fenced.rs +++ b/src/construct/code_fenced.rs @@ -110,12 +110,14 @@ //! [html_code]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-code-element //! [html_pre]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element -use crate::constant::{CODE_FENCED_SEQUENCE_SIZE_MIN, TAB_SIZE}; use crate::construct::partial_space_or_tab::{space_or_tab, space_or_tab_min_max}; use crate::event::{Content, Link, Name}; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; -use crate::util::slice::{Position, Slice}; +use crate::util::{ + constant::{CODE_FENCED_SEQUENCE_SIZE_MIN, TAB_SIZE}, + slice::{Position, Slice}, +}; /// Start of fenced code. /// diff --git a/src/construct/code_indented.rs b/src/construct/code_indented.rs index c5439f1..866c78e 100644 --- a/src/construct/code_indented.rs +++ b/src/construct/code_indented.rs @@ -53,11 +53,11 @@ //! [html_code]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-code-element //! [html_pre]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-pre-element -use crate::constant::TAB_SIZE; use crate::construct::partial_space_or_tab::{space_or_tab, space_or_tab_min_max}; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +use crate::util::constant::TAB_SIZE; /// Start of code (indented). /// diff --git a/src/construct/frontmatter.rs b/src/construct/frontmatter.rs index dc47bee..74006f6 100644 --- a/src/construct/frontmatter.rs +++ b/src/construct/frontmatter.rs @@ -56,11 +56,11 @@ //! //! [constructs]: crate::Constructs -use crate::constant::FRONTMATTER_SEQUENCE_SIZE; use crate::construct::partial_space_or_tab::space_or_tab; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +use crate::util::constant::FRONTMATTER_SEQUENCE_SIZE; /// Start of frontmatter. /// diff --git a/src/construct/heading_atx.rs b/src/construct/heading_atx.rs index 4ff0143..dd09f74 100644 --- a/src/construct/heading_atx.rs +++ b/src/construct/heading_atx.rs @@ -62,12 +62,12 @@ //! [wiki_setext]: https://en.wikipedia.org/wiki/Setext //! [atx]: http://www.aaronsw.com/2002/atx/ -use crate::constant::{HEADING_ATX_OPENING_FENCE_SIZE_MAX, TAB_SIZE}; use crate::construct::partial_space_or_tab::{space_or_tab, space_or_tab_min_max}; use crate::event::{Content, Event, Kind, Link, Name}; use crate::resolve::Name as ResolveName; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; +use crate::util::constant::{HEADING_ATX_OPENING_FENCE_SIZE_MAX, TAB_SIZE}; use alloc::vec; /// Start of a heading (atx). diff --git a/src/construct/heading_setext.rs b/src/construct/heading_setext.rs index 3adeb38..19d2dda 100644 --- a/src/construct/heading_setext.rs +++ b/src/construct/heading_setext.rs @@ -69,13 +69,12 @@ //! [wiki_setext]: https://en.wikipedia.org/wiki/Setext //! [atx]: http://www.aaronsw.com/2002/atx/ -use crate::constant::TAB_SIZE; use crate::construct::partial_space_or_tab::{space_or_tab, space_or_tab_min_max}; use crate::event::{Kind, Name}; use crate::resolve::Name as ResolveName; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; -use crate::util::skip::opt_back as skip_opt_back; +use crate::util::{constant::TAB_SIZE, skip::opt_back as skip_opt_back}; use alloc::vec; /// At start of heading (setext) underline. diff --git a/src/construct/html_flow.rs b/src/construct/html_flow.rs index bd41aa9..edb500e 100644 --- a/src/construct/html_flow.rs +++ b/src/construct/html_flow.rs @@ -94,20 +94,20 @@ //! [flow]: crate::construct::flow //! [html_text]: crate::construct::html_text //! [paragraph]: crate::construct::paragraph -//! [html_raw_names]: crate::constant::HTML_RAW_NAMES -//! [html_block_names]: crate::constant::HTML_BLOCK_NAMES +//! [html_raw_names]: crate::util::constant::HTML_RAW_NAMES +//! [html_block_names]: crate::util::constant::HTML_BLOCK_NAMES //! [html_parsing]: https://html.spec.whatwg.org/multipage/parsing.html#parsing -use crate::constant::{ - HTML_BLOCK_NAMES, HTML_CDATA_PREFIX, HTML_RAW_NAMES, HTML_RAW_SIZE_MAX, TAB_SIZE, -}; use crate::construct::partial_space_or_tab::{ space_or_tab_with_options, Options as SpaceOrTabOptions, }; use crate::event::Name; use crate::state::{Name as StateName, State}; use crate::tokenizer::Tokenizer; -use crate::util::slice::Slice; +use crate::util::{ + constant::{HTML_BLOCK_NAMES, HTML_CDATA_PREFIX, HTML_RAW_NAMES, HTML_RAW_SIZE_MAX, TAB_SIZE}, + slice::Slice, +}; /// Symbol for `