It was a nice read, and I like the way the idea was presented. But one thing that stood out to me as kind of odd was the distinction between typing lowercase and uppercase characters. Automatically assuming lowercase to be a "keyword" does not seem like the right idea to me. Most sentences on the web might start with a capital, but not all of them will do. (For example here on HN, you have in the nav bar "new | threa…
Foolproof HTML
61–70 of 110 posts
Re: Foolproof HTML
#62> If you have a good strategy for validating your template files, I'd love to hear it! Use S-expression syntax instead of SGML syntax, i.e. instead of: content write ((tag attr value ...) content) and use Lisp to process it. It's actually quite straightforward. You can apply it to XML as well. Everything actually ends up looking a lot prettier this way. See http://weitz.de/cl-who/ for an example of an implemented sys…
Interesting, but you would still have to account for the inconsistencies of html, like: - Standalone, non-closed tags , , , , , etc. - Proper encoding or quoting of [ " ' &] in html attributes - tags and CDATA Probably lots more as well. Not rocket science of course, but you would want a tool where you have some confidence they've covered all of these things.
In guile, (htmlprag) addresses the import[1]. It handles "weird html". The SXML modules[2] can handle encoding and rendering. CDATA is the only thing (that seems to be) missing. I'll have to look into that.
Someone also made a module to render html[3].
[1]http://www.nongnu.org/guile-lib/doc/ref/htmlprag/
[2]https://www.gnu.org/software/guile/manual/guile.html#SXML
[3]https://dthompson.us/rendering-html-with-sxml-and-gnu-guile....
Re: Foolproof HTML
#63Re: Foolproof HTML
#64Re: Foolproof HTML
#65Use Hiccup - a Clojure library. You'll have a good syntax highlighting, see only important stuff (eg. no closing tags because it's Lisp) and much less place to make stupid errors. Many people complain about plethora of parents in Lisp code but whatever the syntax is you'll get used to it in <20 hrs.
I already mentioned it in this thread but, check out http://hiccup.space to show people how great it works.
For more in depth examples see http://cljsfiddle.com
Re: Foolproof HTML
#66Re: Foolproof HTML
#67That's 100% possible to do in Emacs, while editing plain html, using smartparens-strict-mode. Basically it treats the HTML like lisp code, so by "autobalancing parens" the editor lets you swap-sexps, which would perform the same transformation as the drag and drop in the editor, but much quicker and easier (as long as u can invest in learning the keys.)!
Of course with Hiccup[0] or Reagent[1] code in Clojure/script, it's perfectly possible too. The same keybindings even.
[0] http://hiccup.space [1] http://cljsfiddle.com
(I'm the author of those little projects)
Re: Foolproof HTML
#68Earlier quoted context omitted.
The problem with these environments is that humans routinely want to write syntactically incorrect code as they transition from one valid program to another. An AST-based editor like this enforces that every intermediate step must parse as a valid program. This restriction makes making changes a massive pain in the ass, because you can no longer take the shortest route from where you are to where you want to be. For…
That's an interesting point. I've heard other people bring up this issue in a vague way, but your example makes it clear why people would have a concern about this. At the same time, however, I'm not convinced it's a serious issue—it's more important to save work and avoid re-typing the shell of a switch when you have to type it one character at a time. If you're mapping language constructs to single keys (this was t…
If you don't have the time/inclination to just do it cause it's a cool project, one option is to "paper prototype" the feasibility of the transforms you'd need.
Next time you're writing any code in the first language you want to support in that AST editor, take a screen recording of at least half an hour's coding. Watch it back later, and keep a count of how many times you:
* transition from one valid program to another in a simple way (eg just writing a line of code from scratch that's valid first time)
* transition in a way that would require abandoning your keyboard and reaching for your mouse in your editor (NB this is a seriously slow operation, usually taking a couple of seconds or more).
* transition in a complex way your editor would support if it had that kind of transform built in (eg if/else-> switch), and work out exactly how clever that transform would have to be (would it work if the if/elses weren't simple equality checks? If they weren't, how would you make the transform if you weren't allowed any non-compiling code?) Then enumerate the distinct such transforms you'd need to cover that half-hour of typing. (You will probably discover a Pareto-type distribution - the question is how tight the head/long the tail is. My guess is you'd need a huge number of special transforms to cover 95% of your edits, but data beats guessing)
* Jump around between statements (eg half-write something, leave it in an utterly broken state, then go actually define the variable/function you're using, then jump back and finish your thought). Your editor would have to permit this somehow or it will be really frustrating to use.
Re: Foolproof HTML
#69Earlier quoted context omitted.
It's actually been a standard part of HTML from the very start. It's got nothing to do with browser guessing and it's not new to HTML 5. To give a concrete example for tannhaeuser's point, consider this document: … … This is a completely correct, valid HTML document. The first thing to notice is that it's not a tree made up of elements. That first line is not a tag, and isn't part of the DOM tree. Then we get to the…
> you can't represent all valid HTML documents as S-expressions, at least not in the convenient way people assume Of course you can. Here is how to express your example as an s-expression: ((:!doctype html) (:title "This is the title") (:p "...")) Here it is being rendered by CL-WHO: ? (princ (html ((:!doctype "html")) (:title "This is the title") (:p "..."))) This is the title ...
Re: Foolproof HTML
#70Earlier quoted context omitted.
Interesting, but you would still have to account for the inconsistencies of html, like: - Standalone, non-closed tags , , , , , etc. - Proper encoding or quoting of [ " ' &] in html attributes - tags and CDATA Probably lots more as well. Not rocket science of course, but you would want a tool where you have some confidence they've covered all of these things.
Last time I looked and also worked kind of like .
doesn’t at all. At a stretch, maybe you’re thinking of ?