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

feat: add bullet list element parsing and rendering #111

Merged
merged 19 commits into from
Oct 23, 2023
Merged

Conversation

mhatzl
Copy link
Contributor

@mhatzl mhatzl commented Oct 7, 2023

List of issues that this PR closes

closes #92

Relevant decisions you made in this PR

Removed Blankline symbol

The Blankline symbol was used to indicate two consecutive newlines.
This created problems with prefix matching, because prefix is only matched after newlines.
As a better alternative, the SymbolIterator offers is_empty_line() and consumed_is_empty_line().
Those functions also handle lines only consisting of whitespace symbols.

Adapt peeking_next() to consider matching functions

With this change, peeking_next() no returns the same symbols as next().
This is important for nested elements, because matching functions internally use peeking_next().
Meaning that matching functions of nested elements would not be correct if peeking_next() would not consider the matching functions of outer iterators.

@mhatzl mhatzl requested a review from nfejzic October 7, 2023 17:12
@mhatzl mhatzl added the waiting-on-reviewer Author or assignee is awaiting response from reviewer label Oct 14, 2023
Copy link
Collaborator

@nfejzic nfejzic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

I think we now have a fairly decent parsing framework. Looks like it's pretty flexible and not that hard to work with, and that makes me really happy.

As for the PR itself, I left some comments. Many of them are not directly related to this PR. You can decide for yourself, whether we should tackle this in this PR.

I am almost leaning towards merging this and then tackling the comments in other PRs so that we prevent explosion in number of changes (is already 1+k LOC large, would not like to inflate it even more). So, I will just leave comments for now (neither approved nor changes requested) so we can discuss first how should we go forward.

commons/src/scanner/symbol/iterator/mod.rs Outdated Show resolved Hide resolved
Comment on lines 302 to +312
fn next(&mut self) -> Option<Self::Item> {
if self.end_reached() {
if self.prefix_mismatch || self.end_reached() {
return None;
}

if let Some(end_fn) = self.end_match.clone() {
self.next_matching = true;

if (end_fn)(self) {
self.iter_end = true;
self.next_matching = false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's somewhat hard for me to follow the code in this whole function in general. Could you add some comments in this function explaining the logic, and/or updating documentation on next_matching and similar fields to better explain how are they used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the doc on next_matching. Hopefully this makes this code clearer.

In short: Setting next_matching flag in next() prevents matching in peeking_next() during execution of the matching functions in next(). Matching functions must get the symbols as is, because they define what symbols must be skipped.

commons/src/scanner/symbol/iterator/mod.rs Outdated Show resolved Hide resolved
commons/src/scanner/symbol/iterator/mod.rs Outdated Show resolved Hide resolved
parser/src/elements/atomic/paragraph.rs Show resolved Hide resolved
parser/src/elements/indents/bullet_list.rs Outdated Show resolved Hide resolved
@nfejzic nfejzic merged commit ff6f3af into main Oct 23, 2023
3 checks passed
@nfejzic nfejzic deleted the bullet-list branch October 23, 2023 10:37
@nfejzic nfejzic removed the waiting-on-reviewer Author or assignee is awaiting response from reviewer label Oct 23, 2023
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

Successfully merging this pull request may close these issues.

[REQ] Impl bullet list parsing and rendering
2 participants