-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Markdown comments dissapear on new start when having # chars #7010
Comments
Indeed, a basic markdown support was added (#6232). |
Yep, @mlep is right. The # is a special character which indicates a bibtex string. I am thinking if it would be possible to escape this somehow for the comment field. Related problem in #7012 |
Maybe the internal handling of See the comment org.jabref.model.entry.BibEntry#toString: /**
* This returns a canonical BibTeX serialization. Special characters such as "{" or "&" are NOT escaped, but written
* as is. In case the JabRef "hack" for distinguishing "field = value" and "field = {value}" (in .bib files) is
* used, it is output as "field = {#value#}", which may cause headaches in debugging. We nevertheless do it this way
* to a) enable debugging the internal representation and b) save time at this method.
* <p>
* Serializes all fields, even the JabRef internal ones. Does NOT serialize "KEY_FIELD" as field, but as key.
*/
@Override
public String toString() {
return CanonicalBibEntry.getCanonicalRepresentation(this);
} The handling of /**
* This method handles # in the field content to get valid bibtex strings
* <p>
* For instance, <code>#jan# - #feb#</code> gets <code>jan #{ - } # feb</code> (see @link{org.jabref.logic.bibtex.LatexFieldFormatterTests#makeHashEnclosedWordsRealStringsInMonthField()})
*/ I see following solutions
|
I was just thinking, users may apply the markdown formatter to other fields (e.g. like abstract) to use the new markdown function. So just escaping the comment field may not be a real solution |
Quick recap: left: BibTeX; right: Entry Editor
Solution 1
Just check for Regex:
Solution 2
Solution 3This is domain-driven design to the max ^^. DecisionWe opt for Solution 1, because does not introduce any changes in the documentation and usage of JabRef |
Some thoughts regarding solution 1.
Nitpicking:
|
Not though thourghly, but yes, on the one hand sounds good. On the other hand, I am thinking whether
Damn it. Sure thing. Also URLs having fragments. Disable bibtex field resolving completly in abstract? Maybe, this refs your solution proposed at #7012 (comment). In the devcall, we agreed that only power users use the string power of BibTeX strings (https://docs.jabref.org/advanced/strings). My take was that our UI in the entry editor currently is not that good to support it well (the improvment of the entry editor is Solution 3).
I don't fully understand the RegEx. Naivly, I would have searched for
Ups 😇 |
Hum, yup, my regex was not thought through enough. I was going for Unicode support and thought that a I suppose my argument is that it might be easier to match the strings rather than the markdown, especially if the allowed characters are more limited than
Are you sure you want to jinx it? 😉
Well, disable string resolution for most fields by default. But, I don't know enough about what goes on in the background of JabRef to even know if the settings below would make the comments save correctly. Edit: |
I think that kind of setting seems to be a viable solution |
You might need to spearate the fields by semicolon like for the wrap fields |
@Siedlerchr it appears to have been a user bug, it is now working as expected 😳 Add a third option? Along the lines of "Only resolve strings in..." with some defaults (author, title, date, etc.?), perhaps add categories? |
Hello, is this issue still open? If it is, I would like to work on it. |
I think this issue is still open, but I do not know how it should be solved. |
A quick lookup in http://www.bibtex.org/Format/ hints that "When quotation-marks are used, string concatenation using # is possible, but not when braces are used.". This can be interpreted in such a way that hash characters ('#') SHOULD be left unmodified in values delimited by '{}'. Apparently this was the behaviour of the previous JabRef version, wan't it? If so, values in '{' could be parsed without modification until the matching closing '}', counting only unescaped instances of '{}'; and all other values should be string-expanded. Is this the way bibtex and biber handle them? (I admit that I never use bibtex string definitions, so I can not say for sure how the string definitions behave). |
Just tested: disabling string resolution for the 'abstract' field works; however, the fields in the text entry field need to be separated by semicolon, not by space: |
So it's sufficient to add comment and abstract to the list ofdefault fields |
Seems like this would be a functional workaround. I'm testing right now the setting with 'abstract' and 'note' included; will add 'comment' as well. So far everything is working as needed, at least for me. But is it correct to process strings in '{}' delimited bibtex fields? What you think about the interpretation of the bibtex.org reference above? |
Confirmed: when 'comment' is added to the 'Resolve strings for all fields except:' list, Markdown is saved and read in correctly. |
The suggested workaround helps against tampering with
Saving arbitrary text entered by a user should escape/unescape or encode/decode all special characters used in the format when serialising/deserialising embedded text. |
Curly braces are more complicated as JabRef uses them to detect fields and entry boundaries etc. |
BibLaTeX forum seems to have an answer (https://tex.stackexchange.com/questions/230750/open-brace-in-bibtex-fields): you can encode The encoding method is completely general. JabRef could use any of the encoding/decoding methods to serialise/deserialise user text. Another character that needs special treatment is |
Except that now I see one problem – what if a user wants to put a LaTeX command into the comment? Escaping would prevent this. Two solutions are possible:
|
We have a cleanup formatter for escaping Latex, Latex Cleanup, that does several things, for example escaping a % sign-in a latex compatible way |
That's good news :). Could the Latex Cleaner also escape lone |
I thought this referred to that the
|
There are some examples https://docs.jabref.org/advanced/strings |
It is not clear to me if I am misunderstanding something, but isn't the answer to this question "no"? I.e., BibTeX strings/constants inside of
I believe that supports my claim, but I am not sure. 😛 |
My proposed solution would be:
I would not dig into the curly brace stuff, that might be a latex command or whatever the user adds. |
Note that |
When reading a I'll try to expand my comment from #7010 (comment) We DO NOT have a "good" model for BibTeX strings in JabRef. The currently (bad) model is that each value field of BibTeX is a
(Assuming Currently we have only
JabRef does some parsing at the entry editor and at all formatters. The same issue happens with Strings.
should be
but we have
internally and deal with it during processing of the field values. For a really good fix, we need to introduce and change public Optional<String> getField(Field field) {
return Optional.ofNullable(fields.get(field));
} to public Optional<BibFieldValue> getField(Field field) {
return Optional.ofNullable(fields.get(field));
} And do the hundreds other related changes. |
I stumbled across this issue again and tested it. The solution in the comment works fine: #7010 (comment) So I will go forward and add this to the list of default fields:+ Curly braces inside will also work, but only if you have a pair. A single one only breaks
|
* Change default behavior of resolve bibtex strings Fixes #7010 Fixes #7012 Fixes #8303 * Renaming of fields * fix prefs, remove migration * Fix gui properties and l10n * adjust defaults, fix bst tests * remove obsolete test Fix changelog * fix checkstyle * fix another test * fix comment * Fix typos * add institution * Sort fields alphabetically * Group prefernces at "File": BibTeX strings, Loading, Saving * Remove unused imports * Add ADR-0024 * Add test for comment field * fix tests * Fix markdown in ADR-0024 * ADR-0024: Fix filename and addr to adr.md * ADR-0019: Fix typo * Remove obsolete empty line * Introduce BIBTEX_STRING_START_END_SYMBOL and remove negation - Add org.jabref.logic.bibtex.FieldWriter#BIBTEX_STRING_START_END_SYMBOL - !doNotResolveStrings -> resolveStrings * Remove deprecated constructor FieldWriterPreferences() * Fix test on Windows (CRLF issue) * Add missing context information * Add more tests * Fix negation Co-authored-by: Oliver Kopp <kopp.dev@gmail.com>
We now changed the whole logic and enable BibTeX string resolving only for a couple of fields. This can be adjusted in the options |
Hi, am on sorry, before I open a new issue, just to check: this issue was concerned with a field that includes the |
JabRef version 5.1--2020-08-30--e023aa0 on Ubuntu 20.04
Hi all!
I am trying to add comments in the comment tab to different entries to get myself an own insight of what I am reading. I've read that from version 5.1 on the markdown style is available. What I am trying to do is create sections in the comment: goal, achievement, method, failure... like this:
Goal (#### Goal)
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Achievement (#### Achievement)
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Method (#### Method)
Lorem ipsum dolor sit amet, consectetur adipiscing elit,
I save the changes and everything looks to work correctly but everytime I reopen JabRef the # are gone and so the sections are not longer highlighted.
Goal Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Achievement Lorem ipsum dolor sit amet, consectetur adipiscing elit,
Method Lorem ipsum dolor sit amet, consectetur adipiscing elit,
It is a pain to add the hashes everytime I reopen the software. Do you have any clue how to fix this?
The text was updated successfully, but these errors were encountered: