summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2016-07-13 23:31:26 +0200
committerFlorian Pritz <bluewind@xinu.at>2016-07-13 23:47:27 +0200
commit8518e4cedcfcb2a5c46c244d28a48208f91be561 (patch)
tree906e859beaeddcc33ab6c3f5225e9985561375b4
parenta3c396a1d059e139492ff25d2aee798626e35b2e (diff)
Fix missing empty lines in chromium when copying code
Chromium apparently requires a <br> or some text to be present for a line to be copied to the clipboard. Firefox interprets the \n at the end as line break and copies that if there is no content. Adding an explicit <br> makes chromium work correctly, but firefox still converts the \n. Fix this by putting the \n in an HTML comment. That way the output is still somewhat readable, but both browsers do the correct thing. Signed-off-by: Florian Pritz <bluewind@xinu.at>
-rw-r--r--application/controllers/file.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php
index e1196940c..139496eb9 100644
--- a/application/controllers/file.php
+++ b/application/controllers/file.php
@@ -293,13 +293,17 @@ class File extends MY_Controller {
$anchor = "n-$anchor_id-$line_number";
}
+ if ($line === "") {
+ $line = "<br>";
+ }
+
// Be careful not to add superflous whitespace here (we are in a <code>)
$output .= "<div class=\"table-row\">"
."<a href=\"#$anchor\" class=\"linenumber table-cell\">"
."<span class=\"anchor\" id=\"$anchor\"> </span>"
."</a>"
- ."<span class=\"line table-cell\">".$line."</span>\n";
- $output .= "</div>";
+ ."<span class=\"line table-cell\">".$line."</span><!--\n";
+ $output .= "--></div>";
}
$output .= "</code></div>";