Re: Question on new line behavior

Pascal Bourguignon <[email protected]>
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
> On 21 Nov 2016, at 20:13, Jean Louis <[email protected]> wrote:
> #!/usr/bin/clisp
> (unless (cadr *args*)
> (format t "~a~%" "No arguments specified.")
> (exit 1))
> 
> (defvar link (car *args*))
> (defvar article (string-trim '(#\Space #\Tab #\Newline) (cadr *args*)))
> 
> (format t "~a~a~a~a~a"
> "<p>
> <em>This article is licensed under the <a href=\"http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License\">Creative Commons Attribution-ShareAlike License</a>. It uses material from the <a href=\"" link "\">Wikipedia Article \"" article "\"</a>.</em>
> </p>”)

Add (setf *print-pretty* nil) before printing.


Otherwise, you’re using format wrong.  And defvar.  And special variables.  And unix executable must not have dot extension in their names.


$ cat ./wiki-cl
#!/usr/local/bin/clisp -q -norc
;; -*- mode:lisp -*-

(unless (cadr *args*)
  (format t "~a~%" "No arguments specified.")
  (exit 1))

(defparameter *link*         (car *args*))
(defparameter *article*      (string-trim '(#\Space #\Tab #\Newline) (cadr *args*)))
(defparameter *licence-url*  "http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License")
(defparameter *licence-name* "Creative Commons Attribution-ShareAlike License")

(defmacro p (&body body)
  `(progn (write-line "<p>")
          ,@body
          (write-line "</p>")))

(defmacro em (&body body)
  `(progn (write-line "<em>")
          ,@body
          (write-line "</em>")))

(defun a (url title)
  (format t "<a href=\"~A\">~A</a>" url title))

(defun pcdata (text)
  (write-line text))

(p (em (pcdata "This article is licensed under the")
     (a *licence-url* *licence-name*) (pcdata ".")
     (pcdata "It uses material from the ")
     (a *link* (format nil "Wikipedia Article \"~A\"" *article*)) (pcdata ".")))



$ ./wiki-cl https://en.wikipedia.org/wiki/CLISP CLISP  
<p>
<em>
This article is licensed under the
<a href="http://en.wikipedia.org/wiki/Wikipedia:Text_of_Creative_Commons_Attribution-ShareAlike_3.0_Unported_License">Creative Commons Attribution-ShareAlike License</a>.
It uses material from the 
<a href="https://en.wikipedia.org/wiki/CLISP">Wikipedia Article "CLISP"</a>.
</em>
</p>
[pjb@larissa :0.0 tmp]$ 
-- 
__Pascal J. Bourguignon__



------------------------------------------------------------------------------
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.