Menu

#857 Replace export formatter can't replace \ with /

open
nobody
None
5
2012-11-08
2010-03-19
MarkS
No

When exporting the file link to an HTML webpage, you might want to replace the \ (backslash) by / (forward slash). However, the current Replace formatter does not accept the following line:

\format[\Filelink(pdf),Replace(\,/)](\file)

because of a bug in AbstractParamLayoutFormatter.java which causes JabRef to think that \, is meant to escape the comma. As a result, it only recognizes a single argument to the Replace formatter, which fails silently. Two things that can be done to improve:

* give an error when insufficient arguments are given to the formatter
* fix the formatter (which might be slightly tricky)

Discussion

  • Morten Omholt Alver

    Mark,

    the good news is that you can achieve what you want by using:

    \format[\Filelink(pdf),Replace(\\\\,/)](\file)

    The reason is that a backslash needs to be escaped, so the argument parser doesn't interpret it as an escaped comma. However, the first argument is then sent to the regexp parser, which also requires a literal backslash to be escaped - therefore the need for four backslashes.

    Then there is the error handling. I'll have a look and see what can be done about that.

     
  • MarkS

    MarkS - 2010-03-24

    Morten,

    thanks! I had tried to escape the \, but having 4 backslashes in a row hadn't occurred to me. I understand it now, but it is still rather counter-intuitive. Also, I was confused by the documentation in the exporter sourcecode, which states:

    "The first part is the regular expression to search for. The regular expression is written normally, without extra escape sequences for backslashes."

    From what you've described, it seems to suggest in order to pass the various RegExp formatters, such as \w, \d, etc. you actually do need to escape the backslash. I may be wrong. I'll investigate.

    Mark

     
  • Morten Omholt Alver

    Good point, there seems to be some mismatch in the documentation there.

     

Log in to post a comment.

MongoDB Logo MongoDB