/**
   * Generates a Citation based on the given entry, style, and output format WARNING: the citation
   * is generated with JavaScript which may take some time, better call it in outside the main
   * Thread
   */
  protected static String generateCitation(
      BibEntry entry, String style, CitationStyleOutputFormat outputFormat) {
    try {
      String citeKey = entry.getCiteKeyOptional().orElse("");
      BibTeXEntry bibTeXEntry = new BibTeXEntry(new Key(entry.getType()), new Key(citeKey));
      for (Map.Entry<String, String> field : entry.getFieldMap().entrySet()) {
        String value = UNICODE_TO_LATEX_FORMATTER.format(field.getValue());
        bibTeXEntry.addField(new Key(field.getKey()), new DigitStringValue(value));
      }

      CSLItemData cslItemData = BIBTEX_CONVERTER.toItemData(bibTeXEntry);
      Bibliography bibliography =
          CSL.makeAdhocBibliography(style, outputFormat.getFormat(), cslItemData);
      return bibliography.getEntries()[0];

    } catch (IOException | ArrayIndexOutOfBoundsException e) {
      LOGGER.error("Could not generate BibEntry citation", e);
      return Localization.lang("Cannot generate preview based on selected citation style.");
    } catch (TokenMgrException e) {
      LOGGER.error("Bad character inside BibEntry", e);
      // sadly one cannot easily retrieve the bad char from the TokenMgrError
      return new StringBuilder()
          .append(Localization.lang("Cannot generate preview based on selected citation style."))
          .append(outputFormat == CitationStyleOutputFormat.HTML ? "<br>" : "\n")
          .append(Localization.lang("Bad character inside entry"))
          .append(outputFormat == CitationStyleOutputFormat.HTML ? "<br>" : "\n")
          .append(e.getLocalizedMessage())
          .toString();
    }
  }
 @Override
 public String getPresentationName() {
   return Localization.lang(
       "change field %0 of entry %1 from %2 to %3",
       StringUtil.boldHTML(field),
       StringUtil.boldHTML(entry.getCiteKeyOptional().orElse(Localization.lang("undefined"))),
       StringUtil.boldHTML(oldValue, Localization.lang("undefined")),
       StringUtil.boldHTML(newValue, Localization.lang("undefined")));
 }