From 6b5a70e9cfbe650b9fb13105c0c0289ff623c000 Mon Sep 17 00:00:00 2001 From: mtkennerly Date: Tue, 28 May 2024 21:10:07 -0400 Subject: [PATCH] #43: Fix handling of italic comments after path --- data/manifest.yaml | 14 +++++++------- src/wiki.rs | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/data/manifest.yaml b/data/manifest.yaml index 02691ede..93bd3a26 100644 --- a/data/manifest.yaml +++ b/data/manifest.yaml @@ -231194,12 +231194,12 @@ FlightGear Flight Simulator: - config when: - os: mac - "/flightgear.org/ (Versions before FlightGear 3.0)": + "/flightgear.org": tags: - config when: - os: windows - "/FlightGear (FlightGear 3.0 to FlightGear 2018.3)": + "/FlightGear": tags: - config when: @@ -376726,12 +376726,12 @@ McPixel: id: 220860 McPixel 3: files: - "/progress.json (itch.io Windows 95 and Windows NT versions)": + "/progress.json": tags: - config when: - os: windows - "/settings.json (itch.io Windows 95 and Windows NT versions)": + "/settings.json": tags: - save when: @@ -387174,13 +387174,13 @@ Minecraft Legends: when: - os: windows store: microsoft - "/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/minecraftWorlds/ (Preview)": + "/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/minecraftWorlds": tags: - save when: - os: windows store: microsoft - "/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/minecraftpe/options.txt (Preview)": + "/Packages/Microsoft.MinecraftWindowsBeta_8wekyb3d8bbwe/LocalState/games/com.mojang/minecraftpe/options.txt": tags: - config when: @@ -641806,7 +641806,7 @@ The Sims 2: - save when: - os: mac - "/Library/Containers/com.aspyr.sims2.appstore/Data/Library/Application Support/Aspyr/The Sims 2 (Mac App Store version)": + "/Library/Containers/com.aspyr.sims2.appstore/Data/Library/Application Support/Aspyr/The Sims 2": tags: - save when: diff --git a/src/wiki.rs b/src/wiki.rs index 47ee88c3..c80d32aa 100644 --- a/src/wiki.rs +++ b/src/wiki.rs @@ -746,11 +746,26 @@ pub struct MappedPath { pub fn flatten_path(attribute: &Attribute) -> WikiPath { let mut out = WikiPath::default(); + let mut maybe_irregular_text = false; for piece in &attribute.value.pieces { match piece { - TextPiece::Text { text, .. } => { - out.incorporate_text(text); + TextPiece::Text { text, formatting } => { + match formatting { + wikitext_parser::TextFormatting::Normal => { + if maybe_irregular_text && !text.trim().is_empty() { + out.regularity = Regularity::Irregular; + } + out.incorporate_text(text); + } + wikitext_parser::TextFormatting::Italic + | wikitext_parser::TextFormatting::Bold + | wikitext_parser::TextFormatting::ItalicBold => { + // Italic or bold notes can appear after the path, + // but if we see any more text afterward, then there's a problem. + maybe_irregular_text = true; + } + } } TextPiece::DoubleBraceExpression { tag, attributes } => match tag.to_string().to_lowercase().trim() { "p" | "path" => {