Last active
December 19, 2015 17:39
-
-
Save docwhat/5992954 to your computer and use it in GitHub Desktop.
Windows newlines (`\r`) appearing in the saved output: An example of the bug in GitLab: gitlabhq/gitlabhq#3982 and posted in ace/issues#1515
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/tmp/ | |
/.bundle/ | |
/ace-builds/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.9.3-p448 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>ACE in Action</title> | |
<style type="text/css" media="screen"> | |
#qeditor { | |
position: absolute; | |
top: 0; | |
right: 0; | |
bottom: 2em; | |
left: 0; | |
} | |
#editor, pre { | |
height: 40em; | |
width: 50em; | |
float: left; | |
margin: 1em; | |
border: 1px solid blue; | |
} | |
</style> | |
</head> | |
<body> | |
<form action="ace-windows-newlines.php" method="post"> | |
<pre id="editor"># A markdown document | |
A sample document | |
## Lorem | |
Curabitur blandit tempus porttitor. Nullam quis risus eget urna mollis ornare | |
vel eu leo. Donec ullamcorper nulla non metus auctor fringilla. Curabitur | |
blandit tempus porttitor. | |
Aenean lacinia bibendum nulla sed consectetur. Donec sed odio dui. Morbi leo | |
risus, porta ac consectetur ac, vestibulum at eros. Duis mollis, est non | |
commodo luctus, nisi erat porttitor ligula, eget lacinia odio sem nec elit. | |
## List | |
* one | |
* fish | |
</pre> | |
<?php | |
if(!empty($_POST['file_content'])) { | |
$replace = str_replace("\r", "\\r", $_POST['file_content']); | |
} else { | |
$replace = ''; | |
} | |
?> | |
<pre id="result"><?php echo $replace; ?></pre> | |
<input type="hidden" id="file_content" name="file_content" value="" /> | |
<input type="submit" name="commit" id="commit" /> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript" charset="utf-8"></script> | |
<script src="//cdn.jsdelivr.net/ace/1.1.01/min/ace.js" type="text/javascript" charset="utf-8"></script> | |
<script> | |
var editor = ace.edit("editor"); | |
//editor.setKeyboardHandler("vim"); | |
editor.setTheme("ace/theme/monokai"); | |
editor.getSession().setMode("ace/mode/markdown"); | |
$("#commit").click(function(){ | |
console.log("NARF", JSON.stringify(editor.getValue())); | |
$("#file_content").val(editor.getValue()); | |
$(".file-editor form").submit(); | |
}); | |
</script> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rack-legacy' | |
use Rack::Legacy::Php, Dir.getwd | |
run Rack::File.new Dir.getwd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source "https://rubygems.org" | |
gem "rack-legacy" | |
gem "guard-livereload" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: https://rubygems.org/ | |
specs: | |
coderay (1.0.9) | |
em-websocket (0.5.0) | |
eventmachine (>= 0.12.9) | |
http_parser.rb (~> 0.5.3) | |
eventmachine (1.0.3) | |
ffi (1.9.0) | |
formatador (0.2.4) | |
guard (1.8.1) | |
formatador (>= 0.2.4) | |
listen (>= 1.0.0) | |
lumberjack (>= 1.0.2) | |
pry (>= 0.9.10) | |
thor (>= 0.14.6) | |
guard-livereload (1.4.0) | |
em-websocket (>= 0.5.0) | |
guard (>= 1.8.0) | |
multi_json (~> 1.7) | |
http_parser.rb (0.5.3) | |
listen (1.2.2) | |
rb-fsevent (>= 0.9.3) | |
rb-inotify (>= 0.9) | |
rb-kqueue (>= 0.2) | |
lumberjack (1.0.4) | |
method_source (0.8.1) | |
multi_json (1.7.7) | |
pry (0.9.12.2) | |
coderay (~> 1.0.5) | |
method_source (~> 0.8) | |
slop (~> 3.4) | |
rack (1.5.2) | |
rack-legacy (0.3.5) | |
rack | |
rb-fsevent (0.9.3) | |
rb-inotify (0.9.0) | |
ffi (>= 0.5.0) | |
rb-kqueue (0.2.0) | |
ffi (>= 0.5.0) | |
slop (3.4.5) | |
thor (0.18.1) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
guard-livereload | |
rack-legacy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment