Live data from Hacker News

Lisp-like html as a replacement to bbcode/markup/textile

94.249.190.129

71–80 of 83 posts

Re: Lisp-like html as a replacement to bbcode/markup/textile

#71
No domain name! I love it! How often do we see this on HN? Fantastic.

As for the idea in the title, isn't this more or less what Viaweb did?

Create a DSL for generating HTML elements and structure that can itself be embedded in an HTML page. Then let users POST commands along with their data to your custom interpeter (that you built from Lisp/Scheme).

Re: Lisp-like html as a replacement to bbcode/markup/textile

#72
post #58

Earlier quoted context omitted.

Oleg Kiselyov has done some nice work where he defines SXML, a representation of XML in Scheme, and parsers/ pretty printers between XML and Scheme. This allows you to use hygienic macros (hygiene becomes important in the absence of namespaces). See http://www.okmij.org/ftp/Scheme/xml.html#SXML-spec Lua's table syntax is well-suited to this style of embedding html/xml syntax in a programming language, e.g., if you de…

Most languages will have literals that can be used to easily represent HTML data: [a => {href=>url, name=>'next'}, 'Go to the', [i => 'next'], 'element']; # perl5 [a => {:href(url), :name }, 'Go to the', [:i ], 'element']; # perl6 [:a => {:href=>url, :name=>'next'}, 'Go to the', [:i => 'next'], 'element'] # ruby Your Lua example is very similar to the HTML::AsSubs CPAN module ( https://metacpan.org/module/HTML::AsSub…

Which is, of course, just CGI.pm's html functions again.

Re: Lisp-like html as a replacement to bbcode/markup/textile

#73
I'm a little bit late to the party and haven't had time to read all the comments yet, but I like the idea and the fact that it's written in Erlang.

So I just wanted to ask: is it intended to be open-source? I couldn't find the link to the source on the site and as mentioned I didn't read through comments yet.

EDIT: I skimmed all the comments but still haven't found any mention about source code. Also, I remembered YAJET[1] as something at least equally interesting.

[1]: Home page is here: http://www.yajet.net/ and docs here: http://www.yajet.net/yajet/doc/yajet.html

Re: Lisp-like html as a replacement to bbcode/markup/textile

#74
post #57

Earlier quoted context omitted.

I still don't see a reason for manual linebreaks here, which would mostly be useful for things like poems etc, where you explicitely need to mandate a certain structure. For everything else paragraphs seem a better solution, especially compared to pervasive use for to simulate post-paragraph spacing.

For developers that's right but when normal people are chatting hit enter they expect a new line. I can't assume they mean the new text to be a paragraph unless they specify it. I supposed I could add escaping for newlines but I'm not going to auto either.

If you're aiming for the bbcode sector, sure. Bloggers etc. (i.e. the textile/markdown crowd) would usually expect more well-formed results.

Not sure whether that's a good demographic to aim at. Basically everything is better than bbcode, yet it's quite firmly entrenched after all these years (with a bit of tag-limited HTML and WYSIWYG as alternatives).

Re: Lisp-like html as a replacement to bbcode/markup/textile

#75
post #52

I think that this is an interesting experiment, and reminds me of Clojure's hiccup[1] library. In hiccup, you model html to be rendered as nested vectors and maps, such that bar becomes (html [:span {:class "foo"} "bar"]) Where this is a real win is when you realize that it's just data: (html [:ol (for [x (range 1 4)] [:li x])]) Lisps are well suited to model html. [1] https://github.com/weavejester/hiccup

Ruby has had these type of libraries for years. The original is probably Markaby, but today there are alternatives that are both faster ( https://github.com/camping/mab/ ) and has more features ( http://erector.rubyforge.org/ ). It's an interesting concept, but I find that (1) it's hard to work on it together with designers and (2) for larger templates I don't find it that elegant.

The theme between these efforts seems to me: Instead of a separate language in a separate world, our views are normal objects/data (in all their glory and power) that happen to know how to print themselves as html.

Re: Lisp-like html as a replacement to bbcode/markup/textile

#76

I'm a little bit late to the party and haven't had time to read all the comments yet, but I like the idea and the fact that it's written in Erlang. So I just wanted to ask: is it intended to be open-source? I couldn't find the link to the source on the site and as mentioned I didn't read through comments yet. EDIT: I skimmed all the comments but still haven't found any mention about source code. Also, I remembered YA…

I'm not quite done with it yet. I may post source after I've used it for awhile and worked out any kinks. Honestly doing it in Erlang was not a great idea. I had to do a lot of micro optimization to make it run at reasonable speeds. I hope to rewrite it in D one day and maybe make a NIF plugin.

Re: Lisp-like html as a replacement to bbcode/markup/textile

#77
post #58

Earlier quoted context omitted.

Oleg Kiselyov has done some nice work where he defines SXML, a representation of XML in Scheme, and parsers/ pretty printers between XML and Scheme. This allows you to use hygienic macros (hygiene becomes important in the absence of namespaces). See http://www.okmij.org/ftp/Scheme/xml.html#SXML-spec Lua's table syntax is well-suited to this style of embedding html/xml syntax in a programming language, e.g., if you de…

Most languages will have literals that can be used to easily represent HTML data: [a => {href=>url, name=>'next'}, 'Go to the', [i => 'next'], 'element']; # perl5 [a => {:href(url), :name }, 'Go to the', [:i ], 'element']; # perl6 [:a => {:href=>url, :name=>'next'}, 'Go to the', [:i => 'next'], 'element'] # ruby Your Lua example is very similar to the HTML::AsSubs CPAN module ( https://metacpan.org/module/HTML::AsSub…

   a { ... }
and

   i "next"
are not table elements, they are function applications.

All of your examples use more magic characters than the Lua example I gave.

Re: Lisp-like html as a replacement to bbcode/markup/textile

#78
post #52

Earlier quoted context omitted.

Ruby has had these type of libraries for years. The original is probably Markaby, but today there are alternatives that are both faster ( https://github.com/camping/mab/ ) and has more features ( http://erector.rubyforge.org/ ). It's an interesting concept, but I find that (1) it's hard to work on it together with designers and (2) for larger templates I don't find it that elegant.

The theme between these efforts seems to me: Instead of a separate language in a separate world, our views are normal objects/data (in all their glory and power) that happen to know how to print themselves as html.

I'm certainly no cultist of MVC, but I would tend to agree with them that tightly coupling presentation details to the basic model is usually unwise.

Re: Lisp-like html as a replacement to bbcode/markup/textile

#79

Earlier quoted context omitted.

The theme between these efforts seems to me: Instead of a separate language in a separate world, our views are normal objects/data (in all their glory and power) that happen to know how to print themselves as html.

I'm certainly no cultist of MVC, but I would tend to agree with them that tightly coupling presentation details to the basic model is usually unwise.

You're not supposed to put these into your models. You should create a different class/method that accepts models and returns HTML:

    class TweetWidget
      def initialize(tweet)
        @tweet = tweet
      end
      
      def content; … end
    end

Re: Lisp-like html as a replacement to bbcode/markup/textile

#80
post #77

Earlier quoted context omitted.

Most languages will have literals that can be used to easily represent HTML data: [a => {href=>url, name=>'next'}, 'Go to the', [i => 'next'], 'element']; # perl5 [a => {:href(url), :name }, 'Go to the', [:i ], 'element']; # perl6 [:a => {:href=>url, :name=>'next'}, 'Go to the', [:i => 'next'], 'element'] # ruby Your Lua example is very similar to the HTML::AsSubs CPAN module ( https://metacpan.org/module/HTML::AsSub…

a { ... } and i "next" are not table elements, they are function applications. All of your examples use more magic characters than the Lua example I gave.

The HTML::AsSubs example uses functions and works exactly (see [1]) the same way your Lua code does.

The first set of examples are just to show that you can model HTML data within common Hash/Array literals available in most languages.

re: magic characters - The perl6 example does use some extra shortcut niceties :) However the perl5 example will actually work unchanged in perl6. The Ruby example is only slightly different to perl5 because it uses symbol sigil (Perl like Lua allows barewords on LHS of a table/hash key assignment).

[1] - The only difference is the Lua a() function receives all its content via a single Table. Whereas HTML::AsSubs a() is a variadic function and uses the Hash literal {} for assigning HTML attributes.

Post reply on HN