def some_function return 'Hello, World!' endHere is my code without hack:
def some_function return 'Hello, World!' end
tags excluding the current indentation level of thetag in the document?
I\'m trying to display my code on a website but I\'m having problems preserving the whitespace indentation correctly.
For instance given the following snippet:
Since browsers ignore comments, you can use them to indent your pre
tag contents.
Here is my code with hack:
def some_function
return 'Hello, World!'
end
Here is my code without hack:
def some_function
return 'Hello, World!'
end
NOTE: a main wrapper was added to provide enough space for the comments.
A better solution is to remove the leading white-space using either your build process or back-end rendering process. If you are using node.js, then you can use a stream I wrote called predentation. You can use any language you want to build a similar tool.
Before
Here is my code:
def some_function
return 'Hello, World!'
end
After
Here is my code:
def some_function
return 'Hello, World!'
end
pre
tagspre
elements with white-space: pre
added by CSSSee this answer to remove indentation with JavaScript
white-space: pre