DEV Community

Amir Mullagaliev
Amir Mullagaliev

Posted on

OSD Final Chapter: Part 3

Introduction

During last 1.5 weeks, I've been implementing second PR in JabRef project. Let me refresh your mind, in the last post I talked how I finished the issue in order to get a new one, there I've shared that I got assigned to another issue. In this post, I'm going to talk in details how I worked on the PR, and what challenges were encountered.

What's Issue about

This issue wasn't the same as previous one, for the reason I had to work on enhancement of the project, not a bug. The issue title filed Use Markdown in AI Summary tab. This project has a lot of different tab regarding entry, and one of the tabs called AI Summary, the tab summarizes the pdf content using AI. Currently, this tab outputs summary in plain text(using Markdown syntax):

Image description

My Goal

My goal was to implement switch that changes raw text to Markdown formatted.

Implementation

As it usually happens, I started looking for the files related to AI Summary tab. It took me about 15 minutes, then using debugger I went through the entire functionality to understand how everything works. I understood the functionality, it made a lot of sense of how to implement it. However, I didn't know how to format the plain text into Markdown formatted. The beauty of open-source, that I was able to ask couple of questions regarding it. Eventually, maintainers told me that they have a class responsible for formation. My work was simplified.

First thing first, I implemented a CheckBox that has a listener. Secondly, I implemented a listener. After I opened the PR, I thought that job is done, and I was surprised that it was so easy.

Challenges

However, I've received a feedback, they had a lot of change requests. First of all, I tried to use fxml file to implement the WebView. In JavaFX, WebView is responsible for the appearance of the content that uses HTML or Text formats. The problem related to fxml was that my commits couldn't pass the tests, and I ended up adding WebView programmatically.

I pushed fresh commits, and I have received another feedback, talking about how my output styled, I tried to manually add the styles, but I was told that isn't correct, and I should find a way to use font family and font size based on user preferences. It took me a while to find responsible for it class.

Once I found it, I was confused how would I integrate it into my code. The problem was that the constructor of that class contains a ton of arguments to integrate it, I had to add ton of arguments to the class that I worked on. I decided to look for other ways, searched the classes that integrate that class, and found interesting approach there. The initialization was pretty new to me. They used @Inject before the object of that class was initialized. I still don't understand how it actually works, but I shouldn't use the constructor to get access to the methods of that function. Therefore, that object helped me format my output in user desired style.

Result

Here's the result of my work.

When user checks the CheckBox, the application outputs the summary in formatted Markdown:

Image description

CheckBox unchecked - plain text:

Image description

Another thing to mention, JavaFX has a bug , that it doesn't wrap the text in WebView and TextArea properly. If window reaches certain limitation of the length, text doesn't get wrapped.

Conclusion

This semester was one of the best in my college journey. Especially working on and learning Open-Source. It opened my eyes, and killed the impostor syndrome, now I fully confident that I was cut out to be a programmer. It was such a good experience to work on huge projects, go out of the box. Yeah, the main difference of OSD from any other course, that you are able work on any project, any issue, and there you are able to use any desirable approach. Moreover, we learnt how to run our own blog, it was really enjoyable to track our own progress in text format, this time it wasn't GIT :D

Thank you so much for this priceless experience!

Top comments (0)