Skip to content

Instantly share code, notes, and snippets.

@hashmal
Last active December 16, 2015 10:39
Show Gist options
  • Save hashmal/5421879 to your computer and use it in GitHub Desktop.
Save hashmal/5421879 to your computer and use it in GitHub Desktop.
(=> html) [ :body unquote split snd-fst -> header -> body "<html>" puts
"<head>" puts header ([length? 0 >] while) [ uncons :title= unquote = (!?) [
"<title>" print uncons print "</title>" puts ] ] << "</head>" puts "<body>"
puts body ([length? 0 >] while) [ uncons -> w w :h1 unquote = (if) [ [ "<h1>"
print uncons print "</h1>" puts ] [ w type? :List = (if) [ [ "<p>" print w
print "</p>" puts << ] [ w :h2 unquote = (!?) [ "<h2>" print << uncons print
"</h2>" puts ] ] ] ] ] ] << "</body>" puts "</html>" puts ]
------------------------------------------------------------------------------
(html)
[
title= "Hello, world!"
body
----
h1 "Hello"
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.
Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec
consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget
libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut
porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a
non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut
gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor."
"Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim
sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero
in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam
pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies.
Mauris vitae nisi at sem facilisis semper ac in est."
h2 "World"
"Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique
vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies."
]
@hashmal
Copy link
Author

hashmal commented Apr 19, 2013

Output is:

<html>
<head>
<title>Hello, world!</title>
</head>
<body>
<h1>Hello</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.
Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec
consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget
libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut
porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a
non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut
gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor.</p>
<p>Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim
sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero
in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam
pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies.
Mauris vitae nisi at sem facilisis semper ac in est.</p>
<h2>World</h2>
<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique
vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies.</p>
</body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment