Live data from Hacker News

Beautiful mini language for outputing HTML in Python

shpaml.webfactional.com

41–50 of 74 posts

Re: Beautiful mini language for outputing HTML in Python

#41

> If HTML were truly awesome, then you would not have Wikipedia; you would have Htmlpedia. I don't buy this. The problem with HTML is not that it isn't expressive enough or that it's too hard to use; it's that arbitrary user code can easily compromise the integrity of your website.

I wrote the comment about Wikipedia only to illustrate that HTML, like any standard, is not perfect for every use case.

I find HTML expressive and generally easy to use. I wrote SHPAML in a way that I hope preserves the useful expressiveness of HTML, while eliminating some of the 1990s-style syntax.

Re: Beautiful mini language for outputing HTML in Python

#42

I don't see why I would use that over this: http://lab.xms.pl/markup-generator/ Not only does it have the same syntax (with some improvements), but it also gives me the CSS to work with. AND I don't have to install python. Hooray.

You don't technically need to install python to use SHPAML. You can try it online:

http://shpaml.webfactional.com/tutorial/7

SHPAML is mostly targeted at Python users for now. If you are not using Python, but you like the idea of having a syntax layer on top of HTML, then you should consider other solutions like the markup generator or haml.

Re: Beautiful mini language for outputing HTML in Python

#43
post #19
post #13

Earlier quoted context omitted.

What is the problem with using one language to produce another? How do you think your primary programmin language gets converted to assembly and then to machine code? As far as I am concerned this is a useful abstraction on a trivial problem.

The problem is that this is a trivial problem. Why add an abstraction on top of something that is already so simple?

My problem with HTML is not its lack of simplicity; it is its verbosity. SHPAML solves the (fairly) trivial problem of making HTML less verbose. The abstraction pays off for me insofar as I expect to use SHPAML for the next decade or so, and it's easy to remember the syntax, easy to share the output, etc.

Re: Beautiful mini language for outputing HTML in Python

#45
post #35
post #16

Is HTML that hard to write?

Good HTML is hard to write. Look up HTML source of several major websites, and you will see how badly indented it is. 95% of them won't validate. Look at this page. It doesn't even have a doctype.

That's largely because it's hard to care.

Browsers don't halt when fed less-than-good HTML the same way an interpreter/compiler dies when fed bad syntax.

Re: Beautiful mini language for outputing HTML in Python

#46

There's just something wrong about creating a language with a language to produce about in a third language. As Brian Kernighan told Dustin Hoffman one time, "Learn to code!".

Right, just like creating Python with C is 'just wrong' if you're going to be writing applications that produce HTML?

Re: Beautiful mini language for outputing HTML in Python

#47
post #42

I don't see why I would use that over this: http://lab.xms.pl/markup-generator/ Not only does it have the same syntax (with some improvements), but it also gives me the CSS to work with. AND I don't have to install python. Hooray.

You don't technically need to install python to use SHPAML. You can try it online: http://shpaml.webfactional.com/tutorial/7 SHPAML is mostly targeted at Python users for now. If you are not using Python, but you like the idea of having a syntax layer on top of HTML, then you should consider other solutions like the markup generator or haml.

Still, the markup generator gives you CSS markup as well.

Re: Beautiful mini language for outputing HTML in Python

#48

I no longer fall for languages that only change the syntax for something the author thinks it's cuter...

i use Markdown ( http://daringfireball.net/projects/markdown/ ) regularly rather than directly writing HTML. like this thing, it's also just syntactic sugar, but it's well-designed and makes it so that i can concentrate on writing and not on formatting syntax. my raw text files are much more source-control friendly, since the diffs are clean.

Markdown is different, though. Rather than trying to cram HTML into a yet another pseudo-programming syntax, it tries to generate HTML that matches common plaintext-formatting conventions. You might not guess Markdown-formatted text was written with a formal markup language in mind.

FWIW, there's a C implementation of Markdown called "discount" (http://www.pell.portland.or.us/~orc/Code/discount/) which is crazy fast, easy to embed, and has a couple nice extensions.

(Also, "SHPAML"? Gross.)

Re: Beautiful mini language for outputing HTML in Python

#49
post #42

Earlier quoted context omitted.

You don't technically need to install python to use SHPAML. You can try it online: http://shpaml.webfactional.com/tutorial/7 SHPAML is mostly targeted at Python users for now. If you are not using Python, but you like the idea of having a syntax layer on top of HTML, then you should consider other solutions like the markup generator or haml.

Still, the markup generator gives you CSS markup as well.

Ah, that is indeed a nice feature. When I first looked at haml, I was all about the indentation (being from Python) and rather skeptical of the CSS sugar. But once I ported the CSS sugar to SHPAML, I found I started writing better markup. I haven't bothered to automate any CSS generation from SHPAML, not because I don't think it would be a useful feature, but because I have a lot less experience with CSS to know what the pain points are. (I have pain points with CSS, but they are either just due to my own ignorance or problems not easily solved.)

Re: Beautiful mini language for outputing HTML in Python

#50
post #37
post #33

Earlier quoted context omitted.

It's not the verbosity or lack of it that makes it shareable, it's the fact that it's a standard. Some of these inventions are a bit nicer than the original thing, but not so much that I'd give up being able to share the code with pretty much anyone and everyone. I can do HTML pretty quickly with Emacs' psgml mode, and I'm sure there are other people who specialize in it who can do it even faster with other tools. I…

When you run SHPAML through the preprocessor, it produces HTML that you can share with other people. So it's not that big an issue. Your greater point is well taken, though--using SHPAML is particularly suited to small teams.

Things can get messy if people sending you patches for something generated, rather than patches for the original source, though. Most such transformations aren't trivially reversible.
Post reply on HN