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

Support for PLAIN BB-Code and CODE=rich #36

Merged
merged 29 commits into from
Jul 17, 2020
Merged

Conversation

asccc
Copy link
Member

@asccc asccc commented Jul 11, 2020

Fixes #29
Fixes #30
Fixes #32
Fixes #37

I also added phpunit and wrote some tests as mentioned in #31
We can add phpunit to our phan action, too.

Copy link
Member

@jr-cologne jr-cologne left a comment

Choose a reason for hiding this comment

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

Yep, adding phpunit to our GitHub actions would be cool.

Thank you for fixing/addressing these bugs/issues as well as your additional improvements of the code in general.

I have already provided some feedback, even though you are probably still working on it.
I will go ahead and fix your mistakes in the comments and extract the helper methods for the tests into a trait.

app/CodeFormatterApp.php Outdated Show resolved Hide resolved
tests/Parser/ParserTest.php Outdated Show resolved Hide resolved
tests/Parser/ParserTest.php Outdated Show resolved Hide resolved
tests/Parser/ParserTest.php Show resolved Hide resolved
app/Parser/Parser.php Outdated Show resolved Hide resolved
@asccc
Copy link
Member Author

asccc commented Jul 13, 2020

I had to remove the parser-trait, because currently there is no autoloader in place to load classes inside the tests-folder.

there is no reason the check the text-buffer after a unclosed bbcode,
because the unclosed bbcode consumes the rest of the input anyway.
@asccc asccc marked this pull request as ready for review July 13, 2020 22:34
@asccc
Copy link
Member Author

asccc commented Jul 13, 2020

Argh, i missed the change in composer.json ... autoloading in tests/ was possible ☹️

@jr-cologne
Copy link
Member

Yep, I actually set everything up for phpunit.

@asccc
Copy link
Member Author

asccc commented Jul 13, 2020

I think we're good to go now 😃

@asccc asccc changed the title Support for PLAIN BB-Code and general improvments Support for PLAIN BB-Code and general improvements Jul 14, 2020
@asccc asccc marked this pull request as draft July 14, 2020 10:51
@asccc
Copy link
Member Author

asccc commented Jul 14, 2020

I decided to implement CODE=rich (as mentioned in #37) in this pr, too, because this requires another rewrite of the parser.
It wouldn't make sense to merge this right now.

@jr-cologne
Copy link
Member

Alright, take your time. All looks very good to me. 😃

@asccc asccc changed the title Support for PLAIN BB-Code and general improvements Support for PLAIN BB-Code and CODE=rich Jul 15, 2020
@asccc asccc marked this pull request as ready for review July 15, 2020 10:25
@asccc
Copy link
Member Author

asccc commented Jul 15, 2020

Should work now 😃

@asccc asccc marked this pull request as draft July 15, 2020 15:12
@asccc
Copy link
Member Author

asccc commented Jul 15, 2020

Somehow my latest push is not showing up here?

@asccc asccc marked this pull request as ready for review July 15, 2020 16:38
@asccc asccc marked this pull request as draft July 15, 2020 16:38
@asccc
Copy link
Member Author

asccc commented Jul 15, 2020

Well, anyway @jr-cologne i'm not 100% satisfied with the api. What do you think?
You can see the latest changes in my fork: asccc@40c2803

@jr-cologne
Copy link
Member

jr-cologne commented Jul 15, 2020

Sorry, I have kinda lost track of the changes you have applied here. 😄
I will try to get an overview over your code as well as the API in general in order to answer your question.
Just give me a moment to take a closer look at it.

Copy link
Member

@jr-cologne jr-cologne left a comment

Choose a reason for hiding this comment

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

Ok, to me, the API and such looks perfectly fine.
What do you exactly not like yet?

Skipping the formatter if the language is "text" would probably speed things up a little bit as the formatter wouldn't have to go through all potential formatters to finally find anything which formats plain text. So feel free to make this change.

app/CodeFormatterApp.php Show resolved Hide resolved
app/Parser/NodeList.php Outdated Show resolved Hide resolved
@asccc
Copy link
Member Author

asccc commented Jul 16, 2020

I absolutely don't like the fact that ElemNode's body can be a NodeList or simply a string.
This requires assertions all over the place and makes the tests type unsafe:

grafik

(All the red highlights are failed type-checks).

@asccc asccc marked this pull request as ready for review July 16, 2020 02:06
@asccc
Copy link
Member Author

asccc commented Jul 16, 2020

"Besser wirds erstmal nicht" i guess 😆

@jr-cologne
Copy link
Member

Oops, I accidentally pushed something. I hope I've not broken anything. 😅
Looks like to merged your parser branch...

@jr-cologne
Copy link
Member

jr-cologne commented Jul 16, 2020

Ok, besides one error I get when formatting with prettier, everything looks pretty good. 👍

Here's the output:

Fatal error: Uncaught DevCommunityDE\CodeFormatter\Exceptions\Exception: code formatting failed! stderr: Error: EACCES: permission denied, mkdir '/var/www/.npm' command not found: prettier

Test input:

Hallo
[CODE=css].test { padding: 10px; }[/CODE]
test

This might just be an issue on my end, btw.
If it works for you, feel free to merge.

Before you merge and I forget it: Thank you so much for this huge amount of work you put into this PR! 🥇 🥳 🙌

@asccc asccc merged commit 38ef1fe into dev-community-de:master Jul 17, 2020
@asccc asccc deleted the parser branch July 17, 2020 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants