From 4b8cc9870271302373be730c62afa858c3d09646 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 02:26:50 -0400 Subject: [PATCH 01/13] Add Layout enum. --- src/layout.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 2 files changed, 49 insertions(+) create mode 100644 src/layout.rs diff --git a/src/layout.rs b/src/layout.rs new file mode 100644 index 00000000..5739325f --- /dev/null +++ b/src/layout.rs @@ -0,0 +1,48 @@ +/* + * layout.rs + * + * ftml - Library to parse Wikidot text + * Copyright (C) 2019-2024 Wikijump Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +/// Describes the desired (HTML) DOM layout to be emitted. +/// +/// This is used as a transition mechanism between our dependencies on the pecularities +/// of old, legacy Wikidot HTML generation and a newer better system we are calling the +/// "Wikijump" layout. +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub enum Layout { + Wikidot, + Wikijump, +} + +impl Layout { + #[inline] + pub fn legacy(self) -> bool { + match self { + Layout::Wikidot => true, + Layout::Wikijump => false, + } + } + + #[inline] + pub fn description(self) -> &'static str { + match self { + Layout::Wikidot => "Wikidot (legacy)", + Layout::Wikijump => "Wikijump", + } + } +} diff --git a/src/lib.rs b/src/lib.rs index f4677a87..fa0d061a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -120,6 +120,7 @@ pub mod wasm; pub mod data; pub mod includes; pub mod info; +pub mod layout; pub mod parsing; pub mod preproc; pub mod render; From 0216984894b2e12b4a688e9786193dd466a7a477 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 02:47:23 -0400 Subject: [PATCH 02/13] Add layout to HtmlRender. --- src/render/html/mod.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/render/html/mod.rs b/src/render/html/mod.rs index 7c2762c0..097463d7 100644 --- a/src/render/html/mod.rs +++ b/src/render/html/mod.rs @@ -41,12 +41,22 @@ use super::prelude; use self::attributes::AddedAttributes; use self::context::HtmlContext; use crate::data::PageInfo; +use crate::layout::Layout; use crate::render::{Handle, Render}; use crate::settings::WikitextSettings; use crate::tree::SyntaxTree; #[derive(Debug)] -pub struct HtmlRender; +pub struct HtmlRender { + layout: Layout, +} + +impl HtmlRender { + #[inline] + pub fn new(layout: Layout) -> Self { + HtmlRender { layout } + } +} impl Render for HtmlRender { type Output = HtmlOutput; From 35fb4de9f9025a1892e6a9fcb8cd99c71d584f8e Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 02:52:33 -0400 Subject: [PATCH 03/13] Add Layout to render prelude. --- src/render/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/render/mod.rs b/src/render/mod.rs index 8af85bc3..f40765b9 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -22,6 +22,7 @@ mod prelude { pub use super::Render; pub use crate::data::PageInfo; + pub use crate::layout::Layout; pub use crate::settings::{WikitextMode, WikitextSettings}; pub use crate::tree::{AttributeMap, Container, ContainerType, Element, SyntaxTree}; } From 0625b46d7d85897edbb2daeeeefd7ae7d44eb514 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 03:01:45 -0400 Subject: [PATCH 04/13] Revert "Add layout to HtmlRender." This reverts commit 0216984894b2e12b4a688e9786193dd466a7a477. We will add this to WikitextSettings instead. --- src/render/html/mod.rs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/render/html/mod.rs b/src/render/html/mod.rs index 097463d7..7c2762c0 100644 --- a/src/render/html/mod.rs +++ b/src/render/html/mod.rs @@ -41,22 +41,12 @@ use super::prelude; use self::attributes::AddedAttributes; use self::context::HtmlContext; use crate::data::PageInfo; -use crate::layout::Layout; use crate::render::{Handle, Render}; use crate::settings::WikitextSettings; use crate::tree::SyntaxTree; #[derive(Debug)] -pub struct HtmlRender { - layout: Layout, -} - -impl HtmlRender { - #[inline] - pub fn new(layout: Layout) -> Self { - HtmlRender { layout } - } -} +pub struct HtmlRender; impl Render for HtmlRender { type Output = HtmlOutput; From e9b78d345dd54e9e4c673a3d59eac06d0d17cd50 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 03:43:50 -0400 Subject: [PATCH 05/13] Make Layout enum serializable. --- src/layout.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/layout.rs b/src/layout.rs index 5739325f..6ac30b84 100644 --- a/src/layout.rs +++ b/src/layout.rs @@ -23,7 +23,8 @@ /// This is used as a transition mechanism between our dependencies on the pecularities /// of old, legacy Wikidot HTML generation and a newer better system we are calling the /// "Wikijump" layout. -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[derive(Serialize, Deserialize, Debug, Copy, Clone, Hash, PartialEq, Eq)] +#[serde(rename_all = "kebab-case")] pub enum Layout { Wikidot, Wikijump, From 8d1085c69d6a34e69ebcdc6cd9e949d08b44a731 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 03:44:10 -0400 Subject: [PATCH 06/13] Add Layout to WikitextSettings. --- src/render/html/context.rs | 7 ++++--- src/settings/mod.rs | 13 ++++++++++++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/render/html/context.rs b/src/render/html/context.rs index a4642769..4e05e76a 100644 --- a/src/render/html/context.rs +++ b/src/render/html/context.rs @@ -26,6 +26,7 @@ use super::random::Random; use crate::data::PageRef; use crate::data::{Backlinks, PageInfo}; use crate::info; +use crate::layout::Layout; use crate::next_index::{NextIndex, TableOfContentsIndex}; use crate::render::Handle; use crate::settings::WikitextSettings; @@ -109,7 +110,7 @@ impl<'i, 'h, 'e, 't> HtmlContext<'i, 'h, 'e, 't> { // Build and return HtmlContext { body: String::with_capacity(capacity), - meta: Self::initial_metadata(info), + meta: Self::initial_metadata(info, settings.layout), backlinks: Backlinks::new(), info, handle, @@ -127,7 +128,7 @@ impl<'i, 'h, 'e, 't> HtmlContext<'i, 'h, 'e, 't> { } } - fn initial_metadata(info: &PageInfo<'i>) -> Vec { + fn initial_metadata(info: &PageInfo<'i>, layout: Layout) -> Vec { // Initial version, we can tune how the metadata is generated later. vec![ @@ -139,7 +140,7 @@ impl<'i, 'h, 'e, 't> HtmlContext<'i, 'h, 'e, 't> { HtmlMeta { tag_type: HtmlMetaType::Name, name: str!("generator"), - value: info::VERSION.clone(), + value: format!("{} {}", *info::VERSION, layout.description()), }, HtmlMeta { tag_type: HtmlMetaType::Name, diff --git a/src/settings/mod.rs b/src/settings/mod.rs index a03fa088..bd29dfc3 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -20,6 +20,8 @@ mod interwiki; +use crate::layout::Layout; + pub use self::interwiki::{InterwikiSettings, DEFAULT_INTERWIKI, EMPTY_INTERWIKI}; const DEFAULT_MINIFY_CSS: bool = true; @@ -31,6 +33,11 @@ pub struct WikitextSettings { /// What mode we're running in. pub mode: WikitextMode, + /// What layout we're targeting. + /// + /// For instance, generating Wikidot's legacy HTML structure. + pub layout: Layout, + /// Whether page-contextual syntax is permitted. /// /// This currently refers to: @@ -94,12 +101,13 @@ pub struct WikitextSettings { impl WikitextSettings { /// Returns the default settings for the given [`WikitextMode`]. - pub fn from_mode(mode: WikitextMode) -> Self { + pub fn from_mode(mode: WikitextMode, layout: Layout,) -> Self { let interwiki = DEFAULT_INTERWIKI.clone(); match mode { WikitextMode::Page => WikitextSettings { mode, + layout, enable_page_syntax: true, use_include_compatibility: false, use_true_ids: true, @@ -110,6 +118,7 @@ impl WikitextSettings { }, WikitextMode::Draft => WikitextSettings { mode, + layout, enable_page_syntax: true, use_include_compatibility: false, use_true_ids: false, @@ -120,6 +129,7 @@ impl WikitextSettings { }, WikitextMode::ForumPost | WikitextMode::DirectMessage => WikitextSettings { mode, + layout, enable_page_syntax: false, use_include_compatibility: false, use_true_ids: false, @@ -130,6 +140,7 @@ impl WikitextSettings { }, WikitextMode::List => WikitextSettings { mode, + layout, enable_page_syntax: true, use_include_compatibility: false, use_true_ids: false, From fbc7f2cfaedf596e3ef3d6eaf0d52cd40cd03e97 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 03:51:09 -0400 Subject: [PATCH 07/13] Bump version to v1.25.0 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9056d68f..a5b1837b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ keywords = ["wikidot", "wikijump", "ftml", "parsing", "html"] categories = ["parser-implementations"] exclude = [".gitignore", ".editorconfig"] -version = "1.24.0" +version = "1.25.0" authors = ["Emmie Smith "] edition = "2021" From 3d42cade742718979381e2161a590da15f59f84e Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Mon, 15 Jul 2024 04:16:23 -0400 Subject: [PATCH 08/13] Run rustfmt. --- src/settings/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/settings/mod.rs b/src/settings/mod.rs index bd29dfc3..c9c3d5dd 100644 --- a/src/settings/mod.rs +++ b/src/settings/mod.rs @@ -101,7 +101,7 @@ pub struct WikitextSettings { impl WikitextSettings { /// Returns the default settings for the given [`WikitextMode`]. - pub fn from_mode(mode: WikitextMode, layout: Layout,) -> Self { + pub fn from_mode(mode: WikitextMode, layout: Layout) -> Self { let interwiki = DEFAULT_INTERWIKI.clone(); match mode { From c8a917085dca80231b2c99da2d330c0c7cc14479 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 16 Jul 2024 01:20:04 -0400 Subject: [PATCH 09/13] Pass in Layout to WikitextSettings. --- src/includes/test.rs | 3 ++- src/parsing/check_step.rs | 3 ++- src/parsing/parser.rs | 3 ++- src/parsing/parser_wrap.rs | 3 ++- src/render/html/test.rs | 3 ++- src/render/null.rs | 3 ++- src/test/ast.rs | 3 ++- src/test/id_prefix.rs | 2 ++ src/test/large.rs | 5 +++-- src/test/prop.rs | 3 ++- src/test/settings.rs | 3 ++- 11 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/includes/test.rs b/src/includes/test.rs index 7e218ea0..1c4edea3 100644 --- a/src/includes/test.rs +++ b/src/includes/test.rs @@ -19,11 +19,12 @@ */ use super::{include, DebugIncluder, PageRef}; +use crate::layout::Layout; use crate::settings::{WikitextMode, WikitextSettings}; #[test] fn includes() { - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); macro_rules! test { ($text:expr, $expected:expr $(,)?) => {{ diff --git a/src/parsing/check_step.rs b/src/parsing/check_step.rs index 644dac01..5b0c4b50 100644 --- a/src/parsing/check_step.rs +++ b/src/parsing/check_step.rs @@ -19,6 +19,7 @@ */ use super::{ExtractedToken, ParseError, Parser, Token}; +use crate::layout::Layout; /// Helper function to assert that the current token matches, then step. /// @@ -49,7 +50,7 @@ fn check_step_fail() { use crate::settings::{WikitextMode, WikitextSettings}; let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); let tokenization = crate::tokenize("**Apple** banana"); let mut parser = Parser::new(&tokenization, &page_info, &settings); diff --git a/src/parsing/parser.rs b/src/parsing/parser.rs index fd3fbfb2..89681afe 100644 --- a/src/parsing/parser.rs +++ b/src/parsing/parser.rs @@ -23,6 +23,7 @@ use super::prelude::*; use super::rule::Rule; use super::RULE_PAGE; use crate::data::PageInfo; +use crate::layout::Layout; use crate::render::text::TextRender; use crate::tokenizer::Tokenization; use crate::tree::{ @@ -586,7 +587,7 @@ fn parser_newline_flag() { use crate::settings::WikitextMode; let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); macro_rules! check { ($input:expr, $expected_steps:expr $(,)?) => {{ diff --git a/src/parsing/parser_wrap.rs b/src/parsing/parser_wrap.rs index 9a91c88a..83f90988 100644 --- a/src/parsing/parser_wrap.rs +++ b/src/parsing/parser_wrap.rs @@ -19,6 +19,7 @@ */ use super::Parser; +use crate::layout::Layout; use crate::tree::AcceptsPartial; use std::ops::{Deref, DerefMut}; @@ -68,7 +69,7 @@ fn wrap() { use crate::settings::{WikitextMode, WikitextSettings}; let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); let tokens = crate::tokenize("Test input"); let mut parser = Parser::new(&tokens, &page_info, &settings); diff --git a/src/render/html/test.rs b/src/render/html/test.rs index cb2f8922..d802d751 100644 --- a/src/render/html/test.rs +++ b/src/render/html/test.rs @@ -20,12 +20,13 @@ use super::prelude::*; use super::HtmlRender; +use crate::layout::Layout; use crate::tree::BibliographyList; #[test] fn html() { let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); let result = SyntaxTree::from_element_result( vec![], vec![], diff --git a/src/render/null.rs b/src/render/null.rs index 7f35c01a..68ebd7b2 100644 --- a/src/render/null.rs +++ b/src/render/null.rs @@ -24,6 +24,7 @@ //! and produce a unit value as output. use super::prelude::*; +use crate::layout::Layout; #[derive(Debug)] pub struct NullRender; @@ -46,7 +47,7 @@ fn null() { use crate::tree::BibliographyList; let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); let result = SyntaxTree::from_element_result( vec![], vec![], diff --git a/src/test/ast.rs b/src/test/ast.rs index 09b13d40..6e17ab45 100644 --- a/src/test/ast.rs +++ b/src/test/ast.rs @@ -25,6 +25,7 @@ use super::includer::TestIncluder; use crate::data::{PageInfo, ScoreValue}; +use crate::layout::Layout; use crate::parsing::ParseError; use crate::render::html::HtmlRender; use crate::render::Render; @@ -209,7 +210,7 @@ impl Test<'_> { language: cow!("default"), }; - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); let (mut text, _pages) = crate::include(&self.input, &settings, TestIncluder, || unreachable!()) diff --git a/src/test/id_prefix.rs b/src/test/id_prefix.rs index 7dec909b..26db76c3 100644 --- a/src/test/id_prefix.rs +++ b/src/test/id_prefix.rs @@ -19,6 +19,7 @@ */ use crate::data::{PageInfo, ScoreValue}; +use crate::layout::Layout; use crate::settings::{WikitextMode, WikitextSettings, EMPTY_INTERWIKI}; use crate::tree::{ AttributeMap, Container, ContainerType, Element, ImageSource, ListItem, ListType, @@ -52,6 +53,7 @@ fn isolate_user_ids() { let settings = WikitextSettings { mode: WikitextMode::Page, + layout: Layout::Wikidot, enable_page_syntax: true, use_true_ids: true, use_include_compatibility: false, diff --git a/src/test/large.rs b/src/test/large.rs index e8e39247..853c9e71 100644 --- a/src/test/large.rs +++ b/src/test/large.rs @@ -19,6 +19,7 @@ */ use crate::data::PageInfo; +use crate::layout::Layout; use crate::parsing::{ParseErrorKind, Token}; use crate::settings::{WikitextMode, WikitextSettings}; use crate::tree::{Element, SyntaxTree}; @@ -32,7 +33,7 @@ use std::borrow::Cow; #[test] fn recursion_depth() { let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); // Build wikitext input let mut input = String::new(); @@ -76,7 +77,7 @@ fn large_payload() { const ITERATIONS: usize = 500; let page_info = PageInfo::dummy(); - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); // Build wikitext input let mut input = String::new(); diff --git a/src/test/prop.rs b/src/test/prop.rs index bcf72162..66925c1e 100644 --- a/src/test/prop.rs +++ b/src/test/prop.rs @@ -19,6 +19,7 @@ */ use crate::data::{PageInfo, PageRef}; +use crate::layout::Layout; use crate::render::{html::HtmlRender, text::TextRender, Render}; use crate::settings::{WikitextMode, WikitextSettings}; use crate::tree::attribute::SAFE_ATTRIBUTES; @@ -447,7 +448,7 @@ fn render( tree: SyntaxTree<'static>, page_info: PageInfo<'static>, ) -> R::Output { - let settings = WikitextSettings::from_mode(WikitextMode::Page); + let settings = WikitextSettings::from_mode(WikitextMode::Page, Layout::Wikidot); render.render(&tree, &page_info, &settings) } diff --git a/src/test/settings.rs b/src/test/settings.rs index bb86d4e9..5272dece 100644 --- a/src/test/settings.rs +++ b/src/test/settings.rs @@ -19,6 +19,7 @@ */ use crate::data::PageInfo; +use crate::layout::Layout; use crate::render::{html::HtmlRender, Render}; use crate::settings::{WikitextMode, WikitextSettings}; @@ -36,7 +37,7 @@ fn settings() { macro_rules! check_individual { ($mode:expr, $input:expr, $substring:expr, $contains:expr) => {{ - let settings = WikitextSettings::from_mode($mode); + let settings = WikitextSettings::from_mode($mode, Layout::Wikidot); let mut text = str!($input); crate::preprocess(&mut text); From 218c07f24aeb1fbb31bca694d1b781781ed320ad Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 16 Jul 2024 01:49:45 -0400 Subject: [PATCH 10/13] Add layout to wasm. --- src/wasm/settings.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wasm/settings.rs b/src/wasm/settings.rs index 777d6a0c..52883a3f 100644 --- a/src/wasm/settings.rs +++ b/src/wasm/settings.rs @@ -19,6 +19,7 @@ */ use super::prelude::*; +use crate::layout::Layout as RustLayout; use crate::settings::{ WikitextMode as RustWikitextMode, WikitextSettings as RustWikitextSettings, }; @@ -52,7 +53,7 @@ impl WikitextSettings { } #[wasm_bindgen] - pub fn from_mode(mode: String) -> Result { + pub fn from_mode(mode: String, layout: String) -> Result { let rust_mode = match mode.as_str() { "page" => RustWikitextMode::Page, "draft" => RustWikitextMode::Draft, @@ -62,8 +63,14 @@ impl WikitextSettings { _ => return Err(JsValue::from_str("Unknown mode")), }; + let rust_layout = match layout.as_str() { + "wikidot" => RustLayout::Wikidot, + "wikijump" => RustLayout::Wikijump, + _ => return Err(JsValue::from_str("Unknown layout")), + }; + Ok(WikitextSettings { - inner: Arc::new(RustWikitextSettings::from_mode(rust_mode)), + inner: Arc::new(RustWikitextSettings::from_mode(rust_mode, rust_layout)), }) } } From d7257b66daaa9827c8282ec99c3d1c05c700ffeb Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 16 Jul 2024 01:50:11 -0400 Subject: [PATCH 11/13] Format change for wasm. --- src/wasm/settings.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/wasm/settings.rs b/src/wasm/settings.rs index 52883a3f..a0b9fb8a 100644 --- a/src/wasm/settings.rs +++ b/src/wasm/settings.rs @@ -69,8 +69,7 @@ impl WikitextSettings { _ => return Err(JsValue::from_str("Unknown layout")), }; - Ok(WikitextSettings { - inner: Arc::new(RustWikitextSettings::from_mode(rust_mode, rust_layout)), - }) + let settings = RustWikitextSettings::from_mode(rust_mode, rust_layout); + Ok(WikitextSettings { inner: Arc::new(settings) }) } } From 2d0083b1c4b32a83b4b285263aa52cc40a4f4950 Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 16 Jul 2024 01:51:20 -0400 Subject: [PATCH 12/13] Fix unused import warnings. --- src/parsing/check_step.rs | 2 +- src/parsing/parser.rs | 2 +- src/parsing/parser_wrap.rs | 2 +- src/render/null.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/parsing/check_step.rs b/src/parsing/check_step.rs index 5b0c4b50..0dee03f0 100644 --- a/src/parsing/check_step.rs +++ b/src/parsing/check_step.rs @@ -19,7 +19,6 @@ */ use super::{ExtractedToken, ParseError, Parser, Token}; -use crate::layout::Layout; /// Helper function to assert that the current token matches, then step. /// @@ -47,6 +46,7 @@ pub fn check_step<'r, 't>( #[should_panic] fn check_step_fail() { use crate::data::PageInfo; + use crate::layout::Layout; use crate::settings::{WikitextMode, WikitextSettings}; let page_info = PageInfo::dummy(); diff --git a/src/parsing/parser.rs b/src/parsing/parser.rs index 89681afe..e88de7ad 100644 --- a/src/parsing/parser.rs +++ b/src/parsing/parser.rs @@ -23,7 +23,6 @@ use super::prelude::*; use super::rule::Rule; use super::RULE_PAGE; use crate::data::PageInfo; -use crate::layout::Layout; use crate::render::text::TextRender; use crate::tokenizer::Tokenization; use crate::tree::{ @@ -584,6 +583,7 @@ fn make_shared_vec() -> Rc>> { #[test] fn parser_newline_flag() { + use crate::layout::Layout; use crate::settings::WikitextMode; let page_info = PageInfo::dummy(); diff --git a/src/parsing/parser_wrap.rs b/src/parsing/parser_wrap.rs index 83f90988..c9a5158f 100644 --- a/src/parsing/parser_wrap.rs +++ b/src/parsing/parser_wrap.rs @@ -19,7 +19,6 @@ */ use super::Parser; -use crate::layout::Layout; use crate::tree::AcceptsPartial; use std::ops::{Deref, DerefMut}; @@ -66,6 +65,7 @@ impl Drop for ParserWrap<'_, '_, '_> { #[test] fn wrap() { use crate::data::PageInfo; + use crate::layout::Layout; use crate::settings::{WikitextMode, WikitextSettings}; let page_info = PageInfo::dummy(); diff --git a/src/render/null.rs b/src/render/null.rs index 68ebd7b2..b94a8bca 100644 --- a/src/render/null.rs +++ b/src/render/null.rs @@ -24,7 +24,6 @@ //! and produce a unit value as output. use super::prelude::*; -use crate::layout::Layout; #[derive(Debug)] pub struct NullRender; @@ -44,6 +43,7 @@ impl Render for NullRender { #[test] fn null() { + use crate::layout::Layout; use crate::tree::BibliographyList; let page_info = PageInfo::dummy(); From 70bc41c948126a380d86c7c891844709300c12ad Mon Sep 17 00:00:00 2001 From: Emmie Maeda Date: Tue, 16 Jul 2024 01:58:57 -0400 Subject: [PATCH 13/13] Revert "Format change for wasm." This reverts commit d7257b66daaa9827c8282ec99c3d1c05c700ffeb. --- src/wasm/settings.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/wasm/settings.rs b/src/wasm/settings.rs index a0b9fb8a..52883a3f 100644 --- a/src/wasm/settings.rs +++ b/src/wasm/settings.rs @@ -69,7 +69,8 @@ impl WikitextSettings { _ => return Err(JsValue::from_str("Unknown layout")), }; - let settings = RustWikitextSettings::from_mode(rust_mode, rust_layout); - Ok(WikitextSettings { inner: Arc::new(settings) }) + Ok(WikitextSettings { + inner: Arc::new(RustWikitextSettings::from_mode(rust_mode, rust_layout)), + }) } }