Code in Web Pages

It seems that it has finally become simple to present code in a web page. Here is some example code:

            
                if x < 0
                    "Negative"
                else
                    "Positive"
                end
            
            
            
                if x > 0
                    "Positive"                
                else
                    "Negative"
                end
            
            

This didn't work in the past: the < sign in particular always caused problems. I discovered that it now does work while investigating the markdown="1" attribute. I have used the pre and code tags to display the code. The editor still picks out the < sign in red but it does display okay.

Here is a longer bit of code:

            
                #=
                Given two equal length strings return the number of differences.
                Throw error if the strings are unequal.
                =#
                function distance(a,b)
                    if length(a) != length(b)
                        throw(ArgumentError("distance($a, $b)"))
                    end
                
                    count_not_equal((f,s)) = f != s ? 1 : 0
                    sum(count_not_equal, zip(a, b); init = 0)
                end
            
            

Code can be indented to sit prettily on the source code of the web page and still have a sensible indent from the left side of the browser window. The really good thing is no actual 'markdown' is needed - the raw, unchanged code displays just fine. Better still, using the pre and code combination means that if the browser window is made very narrow the code does not wrap round - which wouldn't be wanted.

And finally, some simple styling is all that is needed to lay it out on the page.

Postscript: the markdown attribute might help in some way but seems not to be strictly necessary. I have removed the attribute from my code sections and it all seems to work. Completely baffled, it never did work in the past! So what is the markdown attribute actually needed for?