aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-19 17:09:16 +0200
committerLibravatar Titus Wormer <tituswormer@gmail.com>2022-08-19 17:09:16 +0200
commit5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5 (patch)
treed5725002bd5b28b91edb9e6e41ce90c9f3d5063d
parentdc6b4ac40a715d724ee597c995eb05ab30baa6e2 (diff)
downloadmarkdown-rs-5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5.tar.gz
markdown-rs-5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5.tar.bz2
markdown-rs-5e6829c2fb79c2b7f59e38f924e2b2900c52b5d5.zip
Refactor to move more things to `util/`
Diffstat (limited to '')
-rw-r--r--build.rs2
-rw-r--r--readme.md4
-rw-r--r--src/compiler.rs2
-rw-r--r--src/construct/autolink.rs6
-rw-r--r--src/construct/block_quote.rs2
-rw-r--r--src/construct/character_reference.rs14
-rw-r--r--src/construct/code_fenced.rs6
-rw-r--r--src/construct/code_indented.rs2
-rw-r--r--src/construct/frontmatter.rs2
-rw-r--r--src/construct/heading_atx.rs2
-rw-r--r--src/construct/heading_setext.rs3
-rw-r--r--src/construct/html_flow.rs12
-rw-r--r--src/construct/html_text.rs2
-rw-r--r--src/construct/label_end.rs2
-rw-r--r--src/construct/list_item.rs2
-rw-r--r--src/construct/partial_label.rs4
-rw-r--r--src/construct/partial_whitespace.rs8
-rw-r--r--src/construct/thematic_break.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--src/tokenizer.rs3
-rw-r--r--src/util/classify_character.rs2
-rw-r--r--src/util/constant.rs (renamed from src/constant.rs)0
-rw-r--r--src/util/decode_character_reference.rs2
-rw-r--r--src/util/mod.rs2
-rw-r--r--src/util/slice.rs2
-rw-r--r--src/util/unicode.rs (renamed from src/unicode.rs)0
26 files changed, 45 insertions, 45 deletions
diff --git a/build.rs b/build.rs
index d518db1..b485bb5 100644
--- a/build.rs
+++ b/build.rs
@@ -92,7 +92,7 @@ fn commonmark() {{
async fn punctuation() {
let url = "https://www.unicode.org/Public/UCD/latest/ucd/UnicodeData.txt";
let data_url = "unicode-data.txt";
- let code_url = "src/unicode.rs";
+ let code_url = "src/util/unicode.rs";
let value = if let Ok(value) = fs::read_to_string(data_url) {
value
diff --git a/readme.md b/readme.md
index f0d371a..bdeff01 100644
--- a/readme.md
+++ b/readme.md
@@ -179,8 +179,6 @@ The files in `src/` are as follows:
— helpers often needed when parsing markdown
- `compiler.rs`
— turns events into a string of HTML
-- `constants.rs`
- — magic numbers and sets used in markdown
- `event.rs`
— things with meaning happening somewhere
- `lib.rs`
@@ -195,8 +193,6 @@ The files in `src/` are as follows:
— handle content in other content
- `tokenizer.rs`
— glue the states of the state machine together
-- `unicode.rs`
- — info on unicode
## Examples
diff --git a/src/compiler.rs b/src/compiler.rs
index ac68504..2e13294 100644
--- a/src/compiler.rs
+++ b/src/compiler.rs
@@ -1,7 +1,7 @@
//! Turn events into a string of HTML.
-use crate::constant::{SAFE_PROTOCOL_HREF, SAFE_PROTOCOL_SRC};
use crate::event::{Event, Kind, Name};
use crate::util::{
+ constant::{SAFE_PROTOCOL_HREF, SAFE_PROTOCOL_SRC},
decode_character_reference::{decode_named, decode_numeric},
encode::encode,
normalize_identifier::normalize_identifier,
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 `<script>` (condition 1).
const RAW: u8 = 1;
diff --git a/src/construct/html_text.rs b/src/construct/html_text.rs
index 26eded9..5aa6137 100644
--- a/src/construct/html_text.rs
+++ b/src/construct/html_text.rs
@@ -51,11 +51,11 @@
//! [html_flow]: crate::construct::html_flow
//! [html_parsing]: https://html.spec.whatwg.org/multipage/parsing.html#parsing
-use crate::constant::HTML_CDATA_PREFIX;
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::HTML_CDATA_PREFIX;
/// Start of HTML (text)
///
diff --git a/src/construct/label_end.rs b/src/construct/label_end.rs
index 41f16d7..4532920 100644
--- a/src/construct/label_end.rs
+++ b/src/construct/label_end.rs
@@ -158,13 +158,13 @@
//! [html_a]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element
//! [html_img]: https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element
-use crate::constant::RESOURCE_DESTINATION_BALANCE_MAX;
use crate::construct::partial_space_or_tab_eol::space_or_tab_eol;
use crate::event::{Event, Kind, Name};
use crate::resolve::Name as ResolveName;
use crate::state::{Name as StateName, State};
use crate::tokenizer::{Label, LabelStart, Tokenizer};
use crate::util::{
+ constant::RESOURCE_DESTINATION_BALANCE_MAX,
normalize_identifier::normalize_identifier,
skip,
slice::{Position, Slice},
diff --git a/src/construct/list_item.rs b/src/construct/list_item.rs
index 13c287a..7228a00 100644
--- a/src/construct/list_item.rs
+++ b/src/construct/list_item.rs
@@ -58,13 +58,13 @@
//! [html_ul]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element
//! [commonmark_block]: https://spec.commonmark.org/0.30/#phase-1-block-structure
-use crate::constant::{LIST_ITEM_VALUE_SIZE_MAX, TAB_SIZE};
use crate::construct::partial_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::{
+ constant::{LIST_ITEM_VALUE_SIZE_MAX, TAB_SIZE},
skip,
slice::{Position, Slice},
};
diff --git a/src/construct/partial_label.rs b/src/construct/partial_label.rs
index 1c1dcec..47ffd90 100644
--- a/src/construct/partial_label.rs
+++ b/src/construct/partial_label.rs
@@ -59,14 +59,14 @@
//! [label_start_link]: crate::construct::label_start_link
//! [label_end]: crate::construct::label_end
//! [code_text]: crate::construct::code_text
-//! [link_reference_size_max]: crate::constant::LINK_REFERENCE_SIZE_MAX
+//! [link_reference_size_max]: crate::util::constant::LINK_REFERENCE_SIZE_MAX
-use crate::constant::LINK_REFERENCE_SIZE_MAX;
use crate::construct::partial_space_or_tab_eol::{space_or_tab_eol_with_options, Options};
use crate::event::{Content, Link, Name};
use crate::state::{Name as StateName, State};
use crate::subtokenize::link;
use crate::tokenizer::Tokenizer;
+use crate::util::constant::LINK_REFERENCE_SIZE_MAX;
/// Start of label.
///
diff --git a/src/construct/partial_whitespace.rs b/src/construct/partial_whitespace.rs
index 707107d..bb25075 100644
--- a/src/construct/partial_whitespace.rs
+++ b/src/construct/partial_whitespace.rs
@@ -54,13 +54,15 @@
//! [text]: crate::construct::text
//! [hard_break_escape]: crate::construct::hard_break_escape
//! [character_escape]: crate::construct::character_escape
-//! [hard_break_prefix_size_min]: crate::constant::HARD_BREAK_PREFIX_SIZE_MIN
+//! [hard_break_prefix_size_min]: crate::util::constant::HARD_BREAK_PREFIX_SIZE_MIN
//! [html]: https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-br-element
-use crate::constant::HARD_BREAK_PREFIX_SIZE_MIN;
use crate::event::{Event, Kind, Name};
use crate::tokenizer::Tokenizer;
-use crate::util::slice::{Position, Slice};
+use crate::util::{
+ constant::HARD_BREAK_PREFIX_SIZE_MIN,
+ slice::{Position, Slice},
+};
use alloc::vec;
/// Resolve whitespace.
diff --git a/src/construct/thematic_break.rs b/src/construct/thematic_break.rs
index 74fd961..f77f83e 100644
--- a/src/construct/thematic_break.rs
+++ b/src/construct/thematic_break.rs
@@ -56,11 +56,11 @@
//! [list-item]: crate::construct::list_item
//! [html]: https://html.spec.whatwg.org/multipage/grouping-content.html#the-hr-element
-use crate::constant::{TAB_SIZE, THEMATIC_BREAK_MARKER_COUNT_MIN};
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, THEMATIC_BREAK_MARKER_COUNT_MIN};
/// Start of thematic break.
///
diff --git a/src/lib.rs b/src/lib.rs
index ba257db..be423c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -9,7 +9,6 @@
extern crate alloc;
mod compiler;
-mod constant;
mod construct;
mod event;
mod parser;
@@ -17,7 +16,6 @@ mod resolve;
mod state;
mod subtokenize;
mod tokenizer;
-mod unicode;
mod util;
use crate::compiler::compile;
diff --git a/src/tokenizer.rs b/src/tokenizer.rs
index 1e99771..0bd1f31 100644
--- a/src/tokenizer.rs
+++ b/src/tokenizer.rs
@@ -8,12 +8,11 @@
//!
//! [`attempt`]: Tokenizer::attempt
-use crate::constant::TAB_SIZE;
use crate::event::{Content, Event, Kind, Link, Name, Point, VOID_EVENTS};
use crate::parser::ParseState;
use crate::resolve::{call as call_resolve, Name as ResolveName};
use crate::state::{call, State};
-use crate::util::edit_map::EditMap;
+use crate::util::{constant::TAB_SIZE, edit_map::EditMap};
use alloc::{boxed::Box, string::String, vec, vec::Vec};
/// Containers.
diff --git a/src/util/classify_character.rs b/src/util/classify_character.rs
index b938502..79ed46a 100644
--- a/src/util/classify_character.rs
+++ b/src/util/classify_character.rs
@@ -1,6 +1,6 @@
//! Utilities to classify characters as whitespace, punctuation, or rest.
-use crate::unicode::PUNCTUATION;
+use crate::util::unicode::PUNCTUATION;
/// Character kinds.
#[derive(Debug, PartialEq, Eq)]
diff --git a/src/constant.rs b/src/util/constant.rs
index 0c82378..0c82378 100644
--- a/src/constant.rs
+++ b/src/util/constant.rs
diff --git a/src/util/decode_character_reference.rs b/src/util/decode_character_reference.rs
index 30b7853..d4c983a 100644
--- a/src/util/decode_character_reference.rs
+++ b/src/util/decode_character_reference.rs
@@ -1,6 +1,6 @@
//! Decode character references.
-use crate::constant::CHARACTER_REFERENCES;
+use crate::util::constant::CHARACTER_REFERENCES;
use alloc::string::{String, ToString};
/// Decode named character references.
diff --git a/src/util/mod.rs b/src/util/mod.rs
index 022c7d6..d2ec0ed 100644
--- a/src/util/mod.rs
+++ b/src/util/mod.rs
@@ -1,6 +1,7 @@
//! Utilities used when processing markdown.
pub mod classify_character;
+pub mod constant;
pub mod decode_character_reference;
pub mod edit_map;
pub mod encode;
@@ -8,3 +9,4 @@ pub mod normalize_identifier;
pub mod sanitize_uri;
pub mod skip;
pub mod slice;
+pub mod unicode;
diff --git a/src/util/slice.rs b/src/util/slice.rs
index 5dcc352..0734d78 100644
--- a/src/util/slice.rs
+++ b/src/util/slice.rs
@@ -1,7 +1,7 @@
//! Deal with bytes.
-use crate::constant::TAB_SIZE;
use crate::event::{Event, Kind, Point};
+use crate::util::constant::TAB_SIZE;
use alloc::string::String;
use core::str;
diff --git a/src/unicode.rs b/src/util/unicode.rs
index 2b79a88..2b79a88 100644
--- a/src/unicode.rs
+++ b/src/util/unicode.rs