How to preserve whitespace indentation of text enclosed in HTML
 tags excluding the current indentation level of the 
 tag in the document?

后端 未结 11 1459
萌比男神i
萌比男神i 2020-12-02 18:32

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:

11条回答
  •  一整个雨季
    2020-12-02 18:39

    This is cumbersome, but it works if code folding is important to you:

            
    def some_funtion
        return 'Hello, World!'
    end

    In your css,

        pre { margin:0 }
    

    In vim, writing your code normally and then executing:

        :s/\t\t\([^\n]\+\)/
    \1<\/pre>/
    

    for each line would work.

提交回复
热议问题