Menu

#440 [manual] Code snippets (as well as regular text) don't copy properly

v1.0 (example)
closed-wont-fix
nobody
manual (41)
5
2019-01-22
2017-07-27
Evan Aad
No

The code snippets given in the manual do not copy properly. This makes it very inconvenient to try out example code. This is actually two problems:

  1. When the mouse is dragged over a code snippet, more often than not either not the entire snippet is highlighted or more than just the snippet is highlighted, and sometimes it appears that there's no way of actually highlighting just the snippet. Trying to use the keyboard instead of the mouse is even worse: it always highlights the entire page.

  2. Once the code snippet, or a part thereof, has been highlighted, a "copy" operation copies ruins the original line breaks, wantonly adding many more line breaks at inappropriate places, and when the copied snippet is then pasted into a document, it takes a lot of effort to delete the redundant line breaks and restore the original text. It is often faster to simply retype the snippet from scratch, even in cases of long snippets.

The above problems are not restricted to code snippets. Even the normal explanatory text of the manual exhibits similar problematic behavior when one tries to copy it to a different document.

Discussion

  • Stefan Pinnow

    Stefan Pinnow - 2018-05-24

    Sorry, but here I am not sure what the problem is. Could you state an example/screenshot of what happens exactly?

    When I copy text and/or code from the manuals PDF I get the exact line breaks of the PDF and "only" the code indentions get lost. But I think this is a general PDF "problem", right?
    (Nowhere I get additional line breaks/empty lines.)

     
  • Evan Aad

    Evan Aad - 2018-05-25

    I attach screenshots to demonstrate the points I made in my original report.

    1. The screenshot named '1' shows my attempt to copy the code snippet on p.
      1086 of the manual. I placed the cursor at the beginning of the code
      snippet, hit the left button, and started to drag to the right. As can be
      seen in the screenshot, the text in the beginning of the page outside the
      code snippet got selected.

    2. The screenshot named '2' shows what happens to the same code snippet
      after I finally managed to select and copy it to the clipboard, when I
      pasted it into a new emacs document. As can be seen in the screenshot, the
      line breaks are not as in the manual.

     

    Last edit: Stefan Pinnow 2018-05-25
  • Henri Menke

    Henri Menke - 2019-01-22

    That is unfixable because different PDF viewer use different heuristics for selecting text. For example with the Evince viewer I can almost perfectly copy-paste the example you quoted, except for color(100bp)=(black)} which the viewer decided is in another column. The Okular viewer copies perfectly, both with rectangle and text selection tool. MuPDF also copies okay but inserts some random newlines. Foxit Reader also copies perfectly.

    Quintessence: Use a different viewer.

     
  • Henri Menke

    Henri Menke - 2019-01-22
    • status: open --> closed-wont-fix
     
MongoDB Logo MongoDB