From bedbef97e81d1b744eaca8825e8e67918ba7ac47 Mon Sep 17 00:00:00 2001 From: Aravinth Manivannan Date: Fri, 17 Feb 2023 18:16:44 +0530 Subject: [PATCH] fix: list formatting DESCRIPTION Medium's array based markup requires the view layer to peek into the next element to terminate the previous element's formatting rules. So a ")); + } + }; + None + } + fn apply_markup(&self, pindex: usize) -> String { if self.markup.type_ == "A" { if let Some(anchor_type) = &self.markup.anchor_type { @@ -295,6 +352,7 @@ pub fn apply_markup<'b>( gists: &'b Option>, ) -> Vec { let mut paragraphs: Vec = Vec::with_capacity(data.content.body_model.paragraphs.len()); + let mut state = ListState::default(); for (pindex, p) in data.content.body_model.paragraphs.iter().enumerate() { let mut pos = PositionMap::default(); if p.type_ == "H3" && pindex == 0 { @@ -333,8 +391,7 @@ pub fn apply_markup<'b>( } let mut content = String::with_capacity(p.text.len()); - let mut in_oli = false; - content += &Markup::start(&p, &gists, pindex, &mut in_oli); + content += &Markup::start(&p, &gists, pindex, &mut state); pos.arr.sort(); if let Some(first) = pos.arr.get(0) { //content += p.text.substring(cur, *first as usize); @@ -351,18 +408,17 @@ pub fn apply_markup<'b>( // } let pos_markups = pos.map.get(point).unwrap(); for m in pos_markups.iter() { - // println!("{}", &m.apply_markup(pindex)); content += &m.apply_markup(pindex); } cur = incr_cur(cur, *point); } log::debug!("LAST"); content += p.text.slice(cur..); - content += &Markup::end(&p, pindex, &mut in_oli); + content += &Markup::end(&p, pindex, &mut state); } else { log::debug!("LAST WITH NO MARKUP"); content += p.text.slice(cur..); - content += &Markup::end(&p, pindex, &mut in_oli); + content += &Markup::end(&p, pindex, &mut state); } paragraphs.push(content); }