edicl / cl-who Goto Github PK
View Code? Open in Web Editor NEWYet another Lisp markup language
Home Page: https://edicl.github.io/cl-who/
Yet another Lisp markup language
Home Page: https://edicl.github.io/cl-who/
Hi, I think there is a problem during the expansion because the symbols esc
fmt
and str
are expanded twice.
e.g.
(with-html-output-to-string (s) (:a :onclick (str "Test")))
expand to "<aTest onclick='Test'></a>"
but I think it makes more sense to expand into "<a onclick='Test'></a>"
.
The following code:
(let ((v "18") (st nil))
(with-html-output (st nil)
(:div :href v)))
Outputs:
(let ((v "18") (st nil))
(with-html-output-to-string (st nil)
(:div :href v)))
returns: "
"(edit - closing parenthesis for balance)
Upon loading in SBCL I get:
WARNING: System definition file #P".../quicklisp/dists/quicklisp/software/cl-who-20220331-git/cl-who.asd" contains definition for system "cl-who-test". Please only define "cl-who" and secondary systems with a name starting with "cl-who/" (e.g. "cl-who/test") in that file.
I'm not sure if this is a bug or I'm doing something silly, I suspect the latter, but I'm curious to know the cause of this. I'm trying to create an h4 tag with some text in it and then a link, like this:
<h4>Foo <a href="/bar/21">➕</a></h4>
The code I'm using is such:
(with-html-output-to-string (*standard-output* nil)
(:h4 (fmt "Foo ~A"
(htm (:a :href (format nil "/bar/~A" 21) "➕")))))
This produces the following output, with an extra '>' mixed in there, hings are all out of order, and some duplication occurs.
<h4><a href='/bar/21'>➕</a>Foo >➕</a></h4>
I've tried all varieties of (str)/(htm)/(format)/(fmt) that I can think of.
Any guidance would be appreciated.
In both ccl (development version 1.10) and sbcl (1.1.14) if I run:
(asdf:operate 'asdf:test-op :cl-who)
I get an error:
got an unexpected error: error while parsing arguments to DEFMACRO WITH-HTML-OUTPUT-TO-STRING:
unknown keyword: :ELEMENT-TYPE; expected one of :INDENT, :PROLOGUE
I am still a novice in common lisp matters and not sure if test-op is even supposed to work with cl-who. Just reporting it in case it is. I can do further diagnosis if you suggest.
Would you please consider adding a :description option to your system definition of cl-who?
Please, make a new release. The latest release in quicklisp suffers from symbol collision in
(who:with-html-output-to-string (who:str) (:a :href ""))
which is really hard to debug.
Is this supposed to work the way it is working currently:
(let ((a "hello"))
(with-html-output (var (make-string-output-stream))
(htm (:a a))))
;=> "</a>"
;expected <a>hello</a>
If so, why and what is the work around?
When a WITH-HTML-OUTPUT is compiled with non-standard print syntax (e.g. print-base 16), that is somehow captured/closed over at compile-time such that even e.g. wrapping the form in WITH-STANDARD-IO-SYNTAX does not help. This is quite unexpected behaviour and also confusing. I'm guessing what happens is in CONVERT-ATTRIBUTES the CONSTANTP attributes are formatted with tilde A at compile-time.
I'd suggest making such compile-time constant folding optional (presumably it's a speed optimization feature?), and also wrapping it in a compile-time WITH-STANDARD-IO-SYNTAX.
Take the following as an example:
(defmacro with-html (&body body)
`(cl-who:with-html-output-to-string (*standard-output* nil :prologue t)
,@body))
(defmacro html-standard-page (&body body)
`(with-html (:body ,@body)))
(defmacro test-g (id)
`(:table (:tr (:td ,id))))
With this code, I would expect (html-standard-page (test-g "15"))
to output something like:
`
15 |
Why doesn't it? Instead I get warnings that :td
etc. are not defined. What am I doing wrong?
I hope this is an OK place to post this, as I wasn't sure where I should go with support questions. Thank you.
The first one reportedly prevents weblocks from working:
(cl-who:with-html-output (*standard-output*) " ")
throws an error.
the fix is here: http://paste.lisp.org/display/131510
The second one is an issue with misplaced declarations, here's a description:
http://paste.lisp.org/display/131509
and a fix:
http://paste.lisp.org/display/131510#1
As in title. I noticed slime integration exists for Parenscript: https://parenscript.common-lisp.dev/reference.html#section-slime-integration
Consider for example:
(who:htm
(:input :type "text" :name "title" :value "My cat's birthday"))
; Renders <input type='text' name='title' value='My cat's birthday' />
This would break since '
is not escaped to '
as required by the XML spec. I think for attributes it generally makes sense to always use escape-string
-minimal, since I don't see a situation where you'd want to be able to inject arbitrary strings into the tags attribute list.
I guess this can't really be changed now without breaking a lot of existing code depending on who already escaping its attributes, but a setting to change this behavior would be nice.
At
http://weitz.de/cl-who/#with-html-output
In
"CL-WHO will usually try not to insert any unnecessary whitespace in order to save bandwidth. However, if indent is true line breaks will be inserted and nested tags will be indented properly. The value of indent - if it is an integer - will be taken as the initial indentation. If it is not an integer it is assumed to mean 0. Value of HTML-NO-INDENT-TAGS controls which tag-contents are excempt from indentation..."
by adding a comma.
In "(defmacro with-html-output-to-string..." at
http://weitz.de/cl-who/#with-html-output-to-string
is the text "(with-output-to-string (,var ,string-form :elementy-type ,element-type)" which, perhaps, should be "
(with-output-to-string (,var ,string-form :element-type ,element-type)".
I think the text "elementy" is a typo.
"Ciao, Edi"
(a pun on a song by The Cult, named "Edie (Ciao Baby)")
Thank all of you very much for your work, and for making it available.
(let ((x "hi"))
(with-html-output-to-string (s)
(:a :href (str x))))
=> "<ahi href='hi'></a>"
When installing CL-WHO via Quicklisp, version 0.11.1 is installed. This version does not include :HTML5 support. If possible, please release 0.11.2 (or something similar) with support for HTML5 (which is in the git repo anyway) for Quicklisp.
Thanks!
At
http://weitz.de/cl-who/#*html-no-indent-tags*
In
"The list of HTML tags that should disable indentation inside them even when indentation is requested. The initial value is a list containing only :pre and :texarea."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.