Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fragments are occasionally skipped #202

Open
toiletbril opened this issue Feb 16, 2025 · 1 comment
Open

Fragments are occasionally skipped #202

toiletbril opened this issue Feb 16, 2025 · 1 comment

Comments

@toiletbril
Copy link

Hello! Thanks for the awesome library. I use it in my project, dedoc.

Some time ago, I encountered a problem that occasionally, even though they are present in the HTML, the fragments are skipped and nowhere to be found in TaggedLine's elements.

I took time to investigate, and it seems that this bug occurs when FragmentStart is the only element in the tagged line.

Since the TaggedLineElement is considered as having no content if it's a FragmentStart:

impl<T> TaggedLineElement<T> {
/// Return true if this element is non-empty.
/// FragmentStart is considered empty.
fn has_content(&self) -> bool {
match self {
TaggedLineElement::Str(_) => true,
TaggedLineElement::FragmentStart(_) => false,
}
}
}

The TaggedLine is considered empty when it's made exclusively of FragmentStart elements:
fn is_empty(&self) -> bool {
for elt in &self.v {
if elt.has_content() {
return false;
}
}
true
}

TaggedLine, which contain only FragmentStart elements are lost. Seems like due to this condition:

if !self.word.is_empty() {

Attached is an page with fragments, taken from golang documentation, which is affected by the issue.
example_page.txt

Is this the desired behavior?

@jugglerchris
Copy link
Owner

Thanks for the report and detailed investigation!

That does seem wrong - I think even if suppressing blank lines, any fragments ought to be carried over to the next one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants