Add “Copy Without Line Breaks” action to remove line breaks when copying text
Overwiew
This PR adds a “Copy Text (Without line breaks)” option to Okular’s text-selection context menu. Unlike the default copy, which preserves PDF-generated line breaks and hyphenated word splits, the new action:
- Merges hyphenated words broken at line ends (e.g. hyphen-\nbreak → hyphenbreak),
- Replaces single line breaks within paragraphs with spaces,
- Collapses redundant whitespace into single spaces.
Tasks:
-
Implement the functionality -
Add tests
Motivation
I personally use Zotero and Okular and to read article and papers. This kind of copying text is what Zotero already have, which makes the life easier while copying texts and pasting them somewhere else! So I decided it would be a nice feature for Okular, too!
Testing
The original text from the PDF:
Copy Text (Normal copied text):
Flow cells (m-Slide III 3in1 Flow Kit; ibidi GmbH, Martinsried, Germa-
ny) were used for the biocatalytic reactions (the design and dimen-
sions of the flow cells are shown in Figures SI1 and SI2 in the Sup-
porting Information). A Shimadzu UV-2450 UV/Vis spectrophotome-
ter with flow-through quartz cuvettes (Spectrecology, 583.65 style
flow cell, 1 cm optical pathway) connected to the tubing of the
flow device was used for all optical measurements (see Figure SI3).
The reacting solutions were pumped through the flow cells and
spectrophotometer cuvettes with the help of a peristaltic pump
(Gilson Minipuls 3) connected with polyethylene tubing (1 mm in-
ternal diameter).
Copy Text (without line breaks):
Flow cells (m-Slide III 3in1 Flow Kit; ibidi GmbH, Martinsried, Germany) were used for the biocatalytic reactions (the design and dimensions of the flow cells are shown in Figures SI1 and SI2 in the Supporting Information). A Shimadzu UV-2450 UV/Vis spectrophotometer with flow-through quartz cuvettes (Spectrecology, 583.65 style flow cell, 1 cm optical pathway) connected to the tubing of the flow device was used for all optical measurements (see Figure SI3). The reacting solutions were pumped through the flow cells and spectrophotometer cuvettes with the help of a peristaltic pump (Gilson Minipuls 3) connected with polyethylene tubing (1 mm internal diameter).
Edited by Mohammad Kazemi
