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

Extending comment scanning to resolve #24 #26

Merged
merged 3 commits into from
Mar 3, 2025

Conversation

anthonygam
Copy link
Contributor

Hello @nickng, this project has been very useful for me with formatting my honours thesis, so thank you for maintaining it!

I have been looking into #24. For now, I've just written a unit test reproducing the issue, which fails on my machine. I also tried logging s.String() and it appears to be completely empty.

I would like to try to solve the bug over the next few days. Please let me know if this is welcome, if I've made any mistakes with my test, or if you have any suggestions about how to approach fixing the bug.

@anthonygam anthonygam changed the title Adding unit test for issue #24 Extending comment scanning to resolve #24 Feb 25, 2025
@anthonygam
Copy link
Contributor Author

So far, I have a very simple fix that does not modify the existing grammar. Please let me know if you would prefer a different approach.

Copy link
Owner

@nickng nickng left a comment

Choose a reason for hiding this comment

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

I think this looks good! Just a small comment on the variable name.
I start to think whether it's worth support parsing of comments too down the line, so we don't just strip out comments but can also put them back. 🤔

scanner.go Outdated
@@ -13,13 +13,14 @@ var parseField bool
// scanner is a lexical scanner
type scanner struct {
commentMode bool
ignoreMode bool
Copy link
Owner

Choose a reason for hiding this comment

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

I wonder if it's better to call this "outsideEntry" or something like that to be clear that we're not switching into a different context mode (comment mode is when we're scanning comments, not affected by the grammar), but actually not inside an entry so we can ignore everything.

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 think that's a great idea, definitely a much clearer name. I've updated it in a new commit.

@anthonygam anthonygam marked this pull request as ready for review February 26, 2025 08:55
@anthonygam
Copy link
Contributor Author

anthonygam commented Feb 26, 2025

I think this looks good! Just a small comment on the variable name. I start to think whether it's worth support parsing of comments too down the line, so we don't just strip out comments but can also put them back. 🤔

Oh that's an interesting idea! Are you thinking of doing this with @comment{......@ text, or with all the text in between entries? If it's the latter, then maybe this PR would require a refactor right?

@nickng nickng merged commit 928663e into nickng:main Mar 3, 2025
6 checks passed
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.

2 participants