fixup! 37b213fdafacf85b84282d24112b30b80c78c42f
This commit is contained in:
parent
6717ed38f5
commit
d4214ce431
2 changed files with 16 additions and 1 deletions
13
src/block.rs
13
src/block.rs
|
@ -91,11 +91,22 @@ impl<'s> Parser<'s> {
|
||||||
match &kind {
|
match &kind {
|
||||||
Block::Leaf(l) => {
|
Block::Leaf(l) => {
|
||||||
self.tree.enter(kind, span);
|
self.tree.enter(kind, span);
|
||||||
lines[0] = lines[0].with_start(span.end());
|
let first = &mut lines[0];
|
||||||
|
*first = first.with_start(span.end());
|
||||||
|
// trim starting whitespace of block
|
||||||
|
*first = Span::new(
|
||||||
|
first.end() - first.of(self.src).trim_start().len(),
|
||||||
|
first.end(),
|
||||||
|
);
|
||||||
let len = match l {
|
let len = match l {
|
||||||
CodeBlock { .. } => len - 2,
|
CodeBlock { .. } => len - 2,
|
||||||
_ => len,
|
_ => len,
|
||||||
};
|
};
|
||||||
|
if !matches!(l, Leaf::CodeBlock { .. }) {
|
||||||
|
// trim ending whitespace of block
|
||||||
|
let last = &mut lines[len - 1];
|
||||||
|
*last = last.with_len(last.of(self.src).trim_end().len());
|
||||||
|
}
|
||||||
for line in &lines[0..len] {
|
for line in &lines[0..len] {
|
||||||
self.tree.elem(Atom::Inline, *line);
|
self.tree.elem(Atom::Inline, *line);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,10 @@ impl Span {
|
||||||
Self::new(start, self.end())
|
Self::new(start, self.end())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn with_len(self, len: usize) -> Self {
|
||||||
|
Self::by_len(self.start(), len)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn trim_start(self, n: usize) -> Self {
|
pub fn trim_start(self, n: usize) -> Self {
|
||||||
Self::new(self.start().checked_add(n).unwrap(), self.end())
|
Self::new(self.start().checked_add(n).unwrap(), self.end())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue