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

Remove newlines in PDF annotations #3291

Merged
merged 15 commits into from
Nov 20, 2017
Merged

Remove newlines in PDF annotations #3291

merged 15 commits into from
Nov 20, 2017

Conversation

stefan-kolb
Copy link
Member

@stefan-kolb stefan-kolb commented Oct 12, 2017

Resolves #3280

@stefan-kolb stefan-kolb force-pushed the rm-newline-annotation branch from 1a601b5 to 92cc156 Compare October 12, 2017 14:59
@stefan-kolb stefan-kolb added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Oct 12, 2017
@@ -106,7 +106,10 @@ private String parseContent(final String content) {
return "";
}

return content.trim();
// remove line breaks
String processedContent = content.replace("\r\n", " ").replace("\n", " ").replace("\r", " ");
Copy link
Member

Choose a reason for hiding this comment

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

Can you please reuse the remove new lines formatter here, otherwise this is good to go.

Copy link
Member Author

Choose a reason for hiding this comment

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

@tobiasdiez This does not work with our current conventions, i had it this way before...: Adhere to architecture tests do not use logic from within model

Copy link
Member

Choose a reason for hiding this comment

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

Ok, thats again one of these cases where I don't like our strict architecture tests. One could argue that the Formatter can actually life in model as well, but I don't want to start a war here :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

me neither ;-)

Copy link
Member

Choose a reason for hiding this comment

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

You can use the field formatter it in the view model of the file annotation instead of in the actual model (i.e. the actual model contains the text as it was in the pdf, but it is shown without line breaks).

public FileAnnotationViewModel(FileAnnotation annotation) {
this.annotation = annotation;
author.set(annotation.getAuthor());
page.set(Integer.toString(annotation.getPage()));
date.set(annotation.getTimeModified().toString().replace('T', ' '));
setupContentProperties(annotation);
}

Copy link
Member

@LinusDietz LinusDietz left a comment

Choose a reason for hiding this comment

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

Code looks good, tests are fine.

I have one suggested improvement, but if we should reach consensus that this is not a good idea, the PR is good to go.

@@ -24,7 +24,7 @@ public String getKey() {
public String format(String value) {
Objects.requireNonNull(value);

return value.replace("\r\n", " ").replace("\n", " ").trim();
return value.replace("\r\n", " ").replace("\n", " ").replace("\r", " ").trim();
Copy link
Member

Choose a reason for hiding this comment

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

I would also add a special treatment for hyphenated words.
Algorithm sketch: If the last character before the line termination symbol is a minus, replace the minus and the line-terminator with an empty string.

"...Jab-\n"
"ref is cool!\n" 

=>

"...JabRef is cool!"

Copy link
Member Author

Choose a reason for hiding this comment

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

What about Key-Account-Manager?

Copy link
Member

Choose a reason for hiding this comment

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

Well... bad luck? words with a dash are quite rare, at least less frequent than hyphens at line breaks.

This is a problem, where we cant make a good decision.

Copy link
Member Author

Choose a reason for hiding this comment

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

Words with a dash are quite rare in English, maybe...

Copy link
Member Author

Choose a reason for hiding this comment

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

We can just add your solution and see if someone complains. I guess leaving the chars as they are is also not a bad decision.

Copy link
Member

Choose a reason for hiding this comment

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

We've discussed this in the DevCall: Please go for the solution suggested by @LinusDietz

@stefan-kolb
Copy link
Member Author

@JabRef/developers Can someone do the localization update for me? The script doesn't work on my end 😢

@Siedlerchr Siedlerchr self-assigned this Nov 8, 2017
@Siedlerchr
Copy link
Member

@stefan-kolb I neither can run the script

@lenhard
Copy link
Member

lenhard commented Nov 8, 2017

Well if #3184 was broken, we can just revert the merge.

@lenhard
Copy link
Member

lenhard commented Nov 18, 2017

@stefan-kolb The localization script is working again. Can you merge master into this and then it should be ready to go.

@LinusDietz
Copy link
Member

Merging now, as this was discussed already in the devcall. The failing test concerning freecite is unrelated and has been fixed in #3445.

@LinusDietz LinusDietz merged commit 33d0423 into master Nov 20, 2017
@LinusDietz LinusDietz deleted the rm-newline-annotation branch November 20, 2017 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants