diff options
author | Alon Zakai <alonzakai@gmail.com> | 2012-03-05 14:25:06 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2012-03-05 14:25:06 -0800 |
commit | 73d6511550ec7ac895818b74360e87f799fd9171 (patch) | |
tree | f3ea31052a7deca951e6dc42b2881aca1ab2627c | |
parent | 1af7db58eefaa110f2748b7c4dd52f8d022f9aa6 (diff) |
properly handle html-unfriendly print() output
-rw-r--r-- | src/shell.html | 5 | ||||
-rw-r--r-- | tests/hello_world_sdl.cpp | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/shell.html b/src/shell.html index 69217b18..a41086b9 100644 --- a/src/shell.html +++ b/src/shell.html @@ -19,7 +19,10 @@ print: (function() { var element = document.getElementById('output'); return function(text) { - element.innerHTML += text.replace('\n', '<br>', 'g') + '<br>'; + text = text.replace(/</g, "<"); + text = text.replace(/>/g, ">"); + text = text.replace('\n', '<br>', 'g'); + element.innerHTML += text + '<br>'; }; })(), canvas: document.getElementById('canvas') diff --git a/tests/hello_world_sdl.cpp b/tests/hello_world_sdl.cpp index df69b055..35aec303 100644 --- a/tests/hello_world_sdl.cpp +++ b/tests/hello_world_sdl.cpp @@ -20,7 +20,8 @@ int main() { if (SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); SDL_Flip(screen); - printf("you should see a colored cube."); + printf("you should see a colored cube.\n"); + printf("and here is some text that should be HTML-friendly: amp: |&| double-quote: |\"| quote: |'| less-than, greater-than, html-like tags: |<cheez></cheez>|\nanother line.\n"); SDL_Quit(); |