* Embedding HTML in Lisp.
@ 2008-06-22 20:53 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-06-22 20:53 UTC (permalink / raw)
To: emacs-devel
Bonjour à tous.
I have to prepare an exam and I needed a good access to a French
dictionary. I considered that the best choice is http://www.cnrtl.fr/,
a database of the "Centre national de la recherche scientifique". This
dictionary is provided in html format.
So I thought how to get access to a html page. I tried to define html.
I define html as « html is a programming language like any other
programming language ».
Being a language, it can be transformed in lisp and evaluated using
the lisp evaluator.
Apart a few special tags (like BR, HR, <tag expr />, etc), the grammar
of the html is identical ( via an isomorphism ) to the lisp grammar:
<tag expr> text </tag> <----> (tag (expr) text)
So I transformed html in lisp via this iso.
<table>
<tr>
<td>x</td>
<td>y</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
</tr>
</table>
will become
(table (tr (td "x") (td "y"))
(tr (td "a") (td "b")))
and this form will be evaluated after the rules of the emacs lisp
evaluator.
Now I have to give the tags' definitions.
I observe that the lisp evaluator will first call the functions `td'
with a string as parameter, and then will call the functions `tr' with
the output of `td' as parameter, and finally will call `table' with a
list of elements that are the ouputs from `tr' functions as parameter.
Hence html is a subset of lisp, in which the functions are the symbols
like table, div, input, center, I, B, et ctera.
So I did so:
1. I downloaded the page from CNRTL.
2. I filtered it to extract just the definition, and cut the unuseful
informations. (using a signal->filter->accumulate library (not
included in the example I send here))
3. I transformed the result using the grammar isomorphism
4. I evaluated the resulted lisp structure.
The result of the 4th step is the context of the filtered html
page (just the definition).
So that was my implementation of html.
Now if I look in the dictionary, to see the definition of html:
http://fr.wikipedia.org/wiki/Hypertext_Markup_Language
« L'Hypertext Markup Language, généralement abrégé HTML, est le
**format de données** conçu pour représenter les pages web. Il permet
notamment d'implanter de l'hypertexte dans le contenu des pages et
repose sur un **langage de balisage**, d’où son nom »
More, look at the definition of «langage de balisage»:
http://fr.wikipedia.org/wiki/Langage_de_balisage
« L'inclusion de balises permet de transférer à la fois la structure
du document et son contenu. Cette structure est compréhensible par un
**programme informatique** , ce qui autorise un affichage personnalisé
selon des règles pré-établies »
So, in the dictionaries, html is considered as a data structure, that
can be rendered by a program. Maybe the lisp evaluator is that program
in my code... and the data structure is a lisp structure obtained by
html->lisp...
When I first read this definition, it sounded me very strange.
I redefined html as a programming language «en tant que tel», as any
other programming language, neither as a «langage de balisage», nor as
«format de données».
In this new implementation of html the emacs lisp user will have all
the liberty to redefine the rendering of every html (= lisp) symbol as
one wishes. For example, if the user does not like the default
implementation of the tag `table', he will know that the tag `table'
is a lisp function that receives as parameter a list that contains
many list (rows), and every such list contains strings that are the
information of columns (depending of the implementation of TD and
TR). The function must return a string that is the image of the
table. More than that, one could attach to this tag everything
semantically, like a cond form in lisp, or progn. But in this case the
html standard would not be accomplished. In lisp a procedure must
always return an object (Lisp_Object) that can be of a few types. In
html we return an object that must be a string or a list, depending on
the html function (id est: we chop, like Edward Scissorhands, the
lisp evaluator and we obtain so a html evaluator).
When a table is inside another table (or any object inside another
object), the inner table will be evaluated first, then the outside
table. Maybe the outside object (function) will not like the
dimensions of the returned image of the inner object, and want to
rescale it. To solve this, during parsing one can add the quoted text
of every procedure after its definition, for example:
(table (tr (td "x") '(td "x") (td "y") '(td "y"))
'(tr (td "x") '(td "x") (td "y") '(td "y"))
(tr
(td
(table (tr (td "a") '(td "a") (td "b") '(td "b"))
(tr (td "x") '(td "x") (td "b") '(td "b")))
'(table (tr (td "a") '(td "a") (td "b") '(td "b"))
(tr (td "x") '(td "x") (td "b") '(td "b"))))
(td "o")))
and, in case the table "x y" will be able to rescale the inner table
"a b". This has the disavantage that the lisp code grows exponentially
with the html tree's deep. Another solution is to insert the
percentage of the current object during the transformation
html->lisp. For example:
(table (tr (td 50 "x") (td 50 "y"))
(tr (td 40 "a") (td 60 "b")))
When the lisp evaluator will call every function, it will know exactly
how huch the width of that element must me.
There are many possibilities to solve this problem.
The transformation of structures from html to lisp in html->lisp is
very inefficient in my implementation (it's just for test) and have to
be embedded in C (with DEFUN) for a good speed.
For the rest, I will write in the near future for myself a few more
filters for a few French newspapers that I read dayly, and I will add
some more definitions like <table, <a href= , <img src= , <hr>,
etc. But I will not define all the tags of the html language; I will
define just that ones that I need for these pages.
The current definitions of div, span, etc, are adapted for the CNRTL
dictionnary. That was just what I needed here. One can test it using
the call (cnrtl-get 'french-word).
I believe that the ideas from this implementation of html (cnrtl), can
be used in future to implement a complete web browser embedded in
emacs lisp, more customizable than any other browser of emacs (in fact
emacs does not have an incorporated web browser).
Html is lisp.
Finally, I wish to dedicate this implementation of html as a
programming language to Julie B. White from San Diego with all the
gratitude for her encouragements and for a beautiful friendship.
Alin C. Soare
PS: I promised 1 year ago that I would send the indentation of
the lisp code in O(n) time complexity, and I will send it, I hope
soon, because I have much to work and I do not have time at this
instant to check it out before.
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Embedding Html in Lisp
@ 2008-06-22 20:56 A Soare
2008-06-22 21:29 ` Drew Adams
2008-06-23 8:33 ` Thien-Thi Nguyen
0 siblings, 2 replies; 22+ messages in thread
From: A Soare @ 2008-06-22 20:56 UTC (permalink / raw)
To: Emacs Dev [emacs-devel]
[-- Attachment #1: Type: text/plain, Size: 7157 bytes --]
Bonjour à tous.
I have to prepare an exam and I needed a good access to a French
dictionary. I considered that the best choice is http://www.cnrtl.fr/,
a database of the "Centre national de la recherche scientifique". This
dictionary is provided in html format.
So I thought how to get access to a html page. I tried to define html.
I define html as « html is a programming language like any other
programming language ».
Being a language, it can be transformed in lisp and evaluated using
the lisp evaluator.
Apart a few special tags (like BR, HR, <tag expr />, etc), the grammar
of the html is identical ( via an isomorphism ) to the lisp grammar:
<tag expr> text </tag> <----> (tag (expr) text)
So I transformed html in lisp via this iso.
<table>
<tr>
<td>x</td>
<td>y</td>
</tr>
<tr>
<td>a</td>
<td>b</td>
</tr>
</table>
will become
(table (tr (td "x") (td "y"))
(tr (td "a") (td "b")))
and this form will be evaluated after the rules of the emacs lisp
evaluator.
Now I have to give the tags' definitions.
I observe that the lisp evaluator will first call the functions `td'
with a string as parameter, and then will call the functions `tr' with
the output of `td' as parameter, and finally will call `table' with a
list of elements that are the ouputs from `tr' functions as parameter.
Hence html is a subset of lisp, in which the functions are the symbols
like table, div, input, center, I, B, et ctera.
So I did so:
1. I downloaded the page from CNRTL.
2. I filtered it to extract just the definition, and cut the unuseful
informations. (using a signal->filter->accumulate library (not
included in the example I send here))
3. I transformed the result using the grammar isomorphism
4. I evaluated the resulted lisp structure.
The result of the 4th step is the context of the filtered html
page (just the definition).
So that was my implementation of html.
Now if I look in the dictionary, to see the definition of html:
http://fr.wikipedia.org/wiki/Hypertext_Markup_Language
« L'Hypertext Markup Language, généralement abrégé HTML, est le
**format de données** conçu pour représenter les pages web. Il permet
notamment d'implanter de l'hypertexte dans le contenu des pages et
repose sur un **langage de balisage**, d’où son nom »
More, look at the definition of «langage de balisage»:
http://fr.wikipedia.org/wiki/Langage_de_balisage
« L'inclusion de balises permet de transférer à la fois la structure
du document et son contenu. Cette structure est compréhensible par un
**programme informatique** , ce qui autorise un affichage personnalisé
selon des règles pré-établies »
So, in the dictionaries, html is considered as a data structure, that
can be rendered by a program. Maybe the lisp evaluator is that program
in my code... and the data structure is a lisp structure obtained by
html->lisp...
When I first read this definition, it sounded me very strange.
I redefined html as a programming language «en tant que tel», as any
other programming language, neither as a «langage de balisage», nor as
«format de données».
In this new implementation of html the emacs lisp user will have all
the liberty to redefine the rendering of every html (= lisp) symbol as
one wishes. For example, if the user does not like the default
implementation of the tag `table', he will know that the tag `table'
is a lisp function that receives as parameter a list that contains
many list (rows), and every such list contains strings that are the
information of columns (depending of the implementation of TD and
TR). The function must return a string that is the image of the
table. More than that, one could attach to this tag everything
semantically, like a cond form in lisp, or progn. But in this case the
html standard would not be accomplished. In lisp a procedure must
always return an object (Lisp_Object) that can be of a few types. In
html we return an object that must be a string or a list, depending on
the html function (id est: we chop, like Edward Scissorhands, the
lisp evaluator and we obtain so a html evaluator).
When a table is inside another table (or any object inside another
object), the inner table will be evaluated first, then the outside
table. Maybe the outside object (function) will not like the
dimensions of the returned image of the inner object, and want to
rescale it. To solve this, during parsing one can add the quoted text
of every procedure after its definition, for example:
(table (tr (td "x") '(td "x") (td "y") '(td "y"))
'(tr (td "x") '(td "x") (td "y") '(td "y"))
(tr
(td
(table (tr (td "a") '(td "a") (td "b") '(td "b"))
(tr (td "x") '(td "x") (td "b") '(td "b")))
'(table (tr (td "a") '(td "a") (td "b") '(td "b"))
(tr (td "x") '(td "x") (td "b") '(td "b"))))
(td "o")))
and, in case the table "x y" will be able to rescale the inner table
"a b". This has the disavantage that the lisp code grows exponentially
with the html tree's deep. Another solution is to insert the
percentage of the current object during the transformation
html->lisp. For example:
(table (tr (td 50 "x") (td 50 "y"))
(tr (td 40 "a") (td 60 "b")))
When the lisp evaluator will call every function, it will know exactly
how huch the width of that element must me.
There are many possibilities to solve this problem.
The transformation of structures from html to lisp in html->lisp is
very inefficient in my implementation (it's just for test) and have to
be embedded in C (with DEFUN) for a good speed.
For the rest, I will write in the near future for myself a few more
filters for a few French newspapers that I read dayly, and I will add
some more definitions like <table, <a href= , <img src= , <hr>,
etc. But I will not define all the tags of the html language; I will
define just that ones that I need for these pages.
The current definitions of div, span, etc, are adapted for the CNRTL
dictionnary. That was just what I needed here. One can test it using
the call (cnrtl-get 'french-word).
I believe that the ideas from this implementation of html (cnrtl), can
be used in future to implement a complete web browser embedded in
emacs lisp, more customizable than any other browser of emacs (in fact
emacs does not have an incorporated web browser).
Html is lisp.
Finally, I wish to dedicate this implementation of html as a
programming language to Julie B. White from San Diego with all the
gratitude for her encouragements and for a beautiful friendship.
Alin C. Soare
PS: I promised 1 year ago that I would send the indentation of
the lisp code in O(n) time complexity, and I will send it, I hope
soon, because I have much to work and I do not have time at this
instant to check it out before.
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: /mnt/lisp/elisp/cnrtl.el --]
[-- Type: text/x-emacs-lisp; name="/mnt/lisp/elisp/cnrtl.el", Size: 14873 bytes --]
(defun concat* (text)
(let ((r ""))
(dolist (i text)
(and (equal i "-") (setq i "\n-"))
(setq r (concat r (format "%s " i ))))
r))
(defun html->read-structure-name (limit buffer offset back)
(with-current-buffer (or buffer (current-buffer))
(skip-chars-forward " ")
(forward-char offset)
(let ((w (upcase (buffer-substring-no-properties
(point) (prog2 (search-forward-regexp limit nil t) (match-beginning 0))))))
(backward-char back)
(if (member (elt w 0) '(?#))
(format "\"%s\"" w)
w))))
(defun html->add-return (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(goto-char (point-min))
(search-forward "<div " nil t)
(while (search-forward "<div " nil t)
(goto-char (match-beginning 0))
(insert-char ?\n 2)
(goto-char (match-end 0)))
(goto-char (point-min))
;;(while (search-forward "</div>" nil t)
;; (goto-char (match-beginning 0))
;; (insert-char ?\n 1)
;; (goto-char (match-end 0))))
))
(defun html->extract-article (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(goto-char (point-min))
(if (search-forward "<div id=\"art" nil t)
(let ((beg (match-beginning 0)) end (n 1))
(while (not (zerop n))
(search-forward "div" nil t)
(cond ((and (equal (char-before (match-beginning 0)) ?/)
(equal (char-before (1- (match-beginning 0))) ?<))
(setq n (1- n)))
((and (equal (char-before (match-beginning 0)) ?<)
(equal (char-after (match-end 0)) ? ))
(setq n (1+ n)))))
(setq end (1+ (match-end 0)))
(list beg end))
(html-fail-proposed-words))))
(defun html-fail-proposed-words (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(let (beg end list-definitions)
(goto-char 1)
(if (search-forward "Le portail vous propose les termes suivants:" nil t)
(progn
(while (search-forward "*" nil t)
(search-forward "<a href=")
(forward-char)
(setq beg (point))
(search-forward "\"")
(backward-char)
(setq end (point))
(setq list-definitions (append list-definitions (list (buffer-substring-no-properties beg end)))))
(erase-buffer)
(insert "\n\nLe portail vous propose les termes suivants: ")
(dolist (i list-definitions)
(insert (format "\n%s"
(substring i (1+ (and i
(equal (elt i 0) ?/)
(string-match "/" i 1))))))))
(erase-buffer)
(insert (format "Le terme %s est introuvable." mot)))
())))
(defun html->filter (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(let ((lim (html->extract-article buffer)))
(if lim
(progn
(setq other-definitions (html->extract-definitions buffer))
(delete-region (cadr lim) (point-max))
(delete-region 1 (car lim))
t)
(switch-to-buffer buffer)
()))))
(defun html->extract-definitions (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(let (beg end a w list-definitions)
(goto-char 1)
(while (search-forward "return sendRequest(5," nil t)
(search-forward "\'")
(setq beg (match-end 0))
(search-forward "\'")
(setq end (match-beginning 0))
(setq a (buffer-substring-no-properties beg end))
(search-forward "<h1>")
(setq beg (match-end 0))
(search-forward "</h1>")
(setq end (match-beginning 0))
(setq w (buffer-substring-no-properties beg end))
(search-forward "<h2>")
(setq beg (match-end 0))
(search-forward "</h2>")
(setq end (match-beginning 0))
(setq w (concat w "-" (buffer-substring-no-properties beg end)))
(setq list-definitions (append list-definitions (list (cons w a)))))
list-definitions )))
(defun html-step-forward (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(and (eobp) (error "il y a une erreur dans le fichier (fin dy fichier)"))
(skip-chars-forward " \f\t\n\r\v")
(let ((p (point)))
(if (equal (char-after) ?<)
(prog1 nil
(search-forward ">" nil t)
(save-excursion (search-backward "<" nil t)
(when (> (point) p)
(error "Charactère défendu dans le texte (position %d - %d)" p (point)))))
(search-forward "<" nil t)
(backward-char)
(skip-chars-backward " \f\t\n\r\v")))))
(defun html-step-backward (&optional buffer)
(with-current-buffer (or buffer (current-buffer))
(skip-chars-backward " \f\t\n\r\v")
(let ((p (point)))
(if (equal (char-before) ?>)
(prog1 nil
(search-backward "<" nil t)
(save-excursion (search-forward ">" nil t)
(when (< (point) p)
(error "Charactère défendu dans le texte (position %d - %d)" (point) p))))
(search-backward ">" nil t)
(forward-char)
(skip-chars-forward " \f\t\n\r\v")))))
(defun cnrtl-get (mot)
(let* ((address (concat "http://www.cnrtl.fr/definition/" (symbol-name mot)))
(coding-system-for-write 'utf-8)
(coding-system-for-read 'utf-8)
(temporary-file-directory
"/tmp/cnrtl/")
(f (prog2 (or (file-exists-p temporary-file-directory)
(make-directory temporary-file-directory))
(make-temp-file (concat "cnrtl" "-" "mot"))))
(buffer (url-retrieve-synchronously address))
other-definitions
)
;;(html-check-coding-system buffer)
(when (html->filter buffer)
(html->add-return buffer)
(with-current-buffer (or buffer (current-buffer)) (write-region nil nil f))
(setq buffer (find-file-noselect f))
(with-current-buffer buffer
(html->lisp)
(goto-char (point-max))
(message "evaluating the html cpde...")
(let ((r (eval-last-sexp t)))
(erase-buffer)
(insert r)
))
(switch-to-buffer buffer)
(goto-char (point-min)))))
(defun html->read-tag nil
(if (equal (char-after) ?<)
(let ((tag-name (prog2
(forward-char)
(html->read-structure-name "[ >]" (current-buffer) 0 1)))
info
name
)
(catch 'END-TAG
(while t
(when (or (looking-at ">") (looking-back ">"))
(throw 'END-TAG 0))
(setq name (html->read-structure-name "[ =>]" (current-buffer) 0 1))
(if (looking-at "=\"")
(setq info (append info (list (cons name (html->read-structure-name
"\"" (current-buffer) 2 0)))))
(setq info (cons (list name) info)))))
(and (looking-at ">") (forward-char))
(cons tag-name info))
nil))
(defun html->read-text nil
(let ((w (buffer-substring-no-properties (point) (prog2 (html-step-forward) (point)))))
(cond ((string-equal w (string 9830)) (setq w "\n\n §"))
((string-equal w (string 8722)) (setq w "\n\n #")))
w))
(defconst html-special-tags
'(("BR" . "NEWLINE")))
(defun html->struct nil
(skip-chars-forward " \f\t\n\r\v")
(let ((p (point)))
(setq s (or (html->read-tag)
(html->read-text)))
(delete-region p (point))
(setq type (cond ((listp s)
(cond ((assoc (car s) html-special-tags)
'SPECIAL-TAG)
((member "/" (cadr s))
'UNUSED-TAG)
((equal (elt (car s) 0) ?/)
'CLOSE-TAG)
(t
'OPEN-TAG)))
('TEXT)))
(setq expr
(cond ((eq type 'SPECIAL-TAG)
(format "(%s) " (cdr (assoc (car s) html-special-tags))))
((eq type 'UNUSED-TAG)
"")
((eq type 'CLOSE-TAG)
(setq depth (1- depth))
") ")
((eq type 'OPEN-TAG)
(setq depth (1+ depth))
(format "(%s \'%s " (car s) (cdr s)))
((eq type 'TEXT)
(format "\"%s\" " s))))))
(defun html->lisp ()
(message "html->lisp start")
(catch 'END
(let ((depth 0)
s
type
expr)
(while t
(html->struct)
(insert expr)
(when (zerop depth)
(throw 'END nil)))))
(message "html->lisp end")
)
(defun html->pretty-print (text indent)
(let (r s)
(setq s (split-string text))
(catch 'STOP
(while t
(let (nl)
(while (or (and s (< (length nl) (- 100 indent)))
(and s (null (string-match "[[:alpha:]]" (substring (car s) 0 1)))
(not (member (elt (car s) 0) '(?\( ?\«) ))))
(setq nl (concat nl (if (member (elt (car s) 0) '(?, ?.)) "" " ")
(car s))
s (cdr s)))
(setq r (concat r (concat "\n" (make-string indent ? ) nl))))
(and (null s)
(throw 'STOP r))))))
;; html definition
(defun B (prop &rest text)
(concat* text))
(defun SUP (prop &rest text)
(concat* text))
(defun I (prop &rest text)
(concat* text))
(defun CENTER (prop &rest text)
(concat* text))
(defun INPUT (prop &rest text)
"")
(defconst div-forbidden-classes nil)
(defun DIV (prop &rest text)
(let* ((dclass (cdr (assoc 'CLASS prop)))
(did (cdr (assoc 'ID prop)))
indent
(E "")
)
(cond ((member dclass div-forbidden-classes)
)
((string-equal (caar prop) "ID")
(setq indent 4))
((string-equal "TLF_PARAPUTIR" dclass)
(and text (setcar (cdr text) (substring (cadr text) (string-match "[[:graph:]]" (cadr text)))))
(setq E (concat* text))
(add-text-properties 0 1 '(face (:foreground "green" )) E)
(setq E (concat "\n\n " E)))
((and text
(string-equal "TLF_PAROTHERS" dclass)
(or (string-match "Prononc." (car text))
(string-match "BBG." (car text))
(string-match "STAT." (car text))
(string-match "Étymol." (car text))))
)
((and text
(string-equal "TLF_PAROTHERS" dclass)
(string-match "Rem." (car text)))
(setq E (concat* text))
(add-text-properties 0 (length E) '(face (:foreground "yellow" )) E)
(setq E (html->pretty-print E 7))
(setq E (concat "\n" E))
)
((string-equal "TLF_CVEDETTE" dclass)
(let* (z
(def (mapcar 'car other-definitions)))
(setq header-line-format (concat "« " (concat* text) " »" (format " %s " def))))
(setq indent nil)
)
((string-equal "TLF_PARAH" dclass)
(and text (setcar text (substring (car text) 0 (string-match " " (car text)))))
(and text (setcar (cdr text) (substring (cadr text) (string-match "[[:graph:]]" (cadr text)))))
(setq E (concat* text))
(setq E (concat "\n\n " E))
)
((string-equal "TLF_TABULATION" dclass)
(setq indent 10))
(t
(setq indent 0)
(setq text (append text '("\n")))))
(if indent
(concat "\n" (make-string indent ? ) (concat* text))
E)))
(defconst span-forbidden-classes nil)
(defun SPAN (prop &rest text)
(let ((sclass (cdar prop)) r i c forbid)
(cond ((member sclass span-forbidden-classes)
"" )
((string-equal sclass "TLF_CMOT")
(setq c '(face (:foreground "red" ))) (concat* text))
((string-equal sclass "TLF_CCODE")
(setq c '(face (:foreground "green" ))) (concat* text))
((string-equal sclass "TLF_CPLAN")
(setq c '(face (:foreground "DeepPink1" ))) (concat* text))
((string-equal sclass "TLF_CEMPLOI")
(setq c '(face (:foreground "cyan" ))
i 3))
((string-equal sclass "TLF_CDEFINITION")
(setq c '(face (:foreground "DodgerBlue" ))
i 5))
((string-equal sclass "TLF_PARAH")
(setq c '(face (:foreground "SlateBlue" ))) (concat* text))
((string-equal sclass "TLF_CSYNONIME")
(setq c '(face (:foreground "MediumSeaGreen" ))
i 10))
((string-equal sclass "TLF_CSYNTAGME")
(setq c '(face (:foreground "DarkGreen" ))
i 12))
((string-equal sclass "TLF_CTITRE")
(setq c '(face (:foreground "LawnGreen" ))
forbid t))
((string-equal sclass "TLF_CCROCHET")
(setq c '(face (:foreground "IndianRed" ))
i 5))
((string-equal sclass "TLF_CAUTEUR")
(setq c '(face (:foreground "DarkKhaki" ))
forbid t))
((string-equal sclass "TLF_SMALLCAPS")
(when text (setq text (list (upcase (concat* text)))
c '(face (:foreground "orange" ))))
)
((string-equal sclass "TLF_CEXEMPLE")
(setq c '(face (:foreground "tomato1" ))
i 15)
)
((string-equal sclass "TLF_CDATE")
(setq c '(face (:foreground "BlueViolet" ))
forbid t))
((string-equal sclass "TLF_CCONSTRUCTION")
(setq c '(face (:foreground "LemonChiffon3" ))
i 14))
((string-equal sclass "TLF_CSOURCE")
(setq c '(face (:foreground "LavenderBlush3" ))) (concat* text))
((string-equal sclass "TLF_CDOMAINE")
(setq c '(face (:foreground "DeepSkyBlue4 " ))) (concat* text))
((string-equal sclass "TLF_CPUBLICATION")
(setq c '(face (:foreground "LemonChiffon3" ))) (concat* text))
(t
(message "balise %s inconnue" sclass)
(setq c '(face (:foreground "LemonChiffon3" )))))
(setq r (concat* text))
(and i (setq r (html->pretty-print r i)))
(add-text-properties 0 (length r) c r)
(if forbid "X" r)))
(defun TR (prop &rest text)
text)
(defun TD (prop &rest text)
text)
(defun TABLE (prop &rest rows)
rows)
(defun NEWLINE (&rest x)
"\n")
;; (cnrtl-get 'marmite)
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Embedding Html in Lisp
2008-06-22 20:56 A Soare
@ 2008-06-22 21:29 ` Drew Adams
2008-06-23 8:33 ` Thien-Thi Nguyen
1 sibling, 0 replies; 22+ messages in thread
From: Drew Adams @ 2008-06-22 21:29 UTC (permalink / raw)
To: alinsoar, 'Emacs Dev [emacs-devel]'
> So I transformed html in lisp
You might be interested in these:
http://homepages.inf.ed.ac.uk/wadler/papers/next700dimacs/next700dimacs.pdf
http://homepages.inf.ed.ac.uk/wadler/papers/xml-essence/xml-essence.pdf
^ permalink raw reply [flat|nested] 22+ messages in thread
* RE: Embedding Html in Lisp
@ 2008-06-22 22:27 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-06-22 22:27 UTC (permalink / raw)
To: Drew Adams; +Cc: emacs-devel
Thanks, but
1. I am not going to write a full web browser, just minimum that I need for a few French pages that I visit.
2. These articles presents the connection LISP <-> XML just syntactically (as a connection between their data types).
It makes no reference to an evaluation of lisp code with tags instead of functions, which is the main problem into a browser.
> > So I transformed html in lisp
>
>
> You might be interested in these:
>
> http://homepages.inf.ed.ac.uk/wadler/papers/next700dimacs/next700dimacs.pdf
>
> http://homepages.inf.ed.ac.uk/wadler/papers/xml-essence/xml-essence.pdf
>
>
>
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-22 20:56 A Soare
2008-06-22 21:29 ` Drew Adams
@ 2008-06-23 8:33 ` Thien-Thi Nguyen
1 sibling, 0 replies; 22+ messages in thread
From: Thien-Thi Nguyen @ 2008-06-23 8:33 UTC (permalink / raw)
To: alinsoar; +Cc: Emacs Dev [emacs-devel]
() A Soare <alinsoar@voila.fr>
() Sun, 22 Jun 2008 22:56:15 +0200 (CEST)
grammar of the html is identical ( via an isomorphism )
to the lisp grammar: [...]
Probably you mean "syntax" instead of "grammar".
Html is lisp.
You dignify html a lot more than it deserves!
thi
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-23 11:49 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-06-23 11:49 UTC (permalink / raw)
To: dhruva; +Cc: Emacs Dev [emacs-devel]
Well, all you have to do is to write definitions of html tags
as lisp functions, and do not forget that the actual implementation
of html->lisp does not solve the rescaling problem, because I did
not need it for Cnrtl.
Alin.
> Hello,
> Thank you for such a nice write up. I am truly amazed, I had never
> realized the similarity between HTML and Lisp! The only similarity I
> stumbled upon was Microsoft Excel Lisp. I play (or am supposed to) a
> lot with XML files at work. We have a standard client/server model in
> which data is exchanged in XML format. I can now think of having
> something done in Emacs! Thanks for opening my eyes.
>
> with best regards,
> dhruva
>
> --
> Contents reflect my personal views only!
>
>
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-23 12:23 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-06-23 12:23 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: Emacs Dev [emacs-devel]
Hello,
Here it's about the concept "formal grammar" , whose name comes from algebra.
So the grammars are isomorphic, etc.
http://en.wikipedia.org/wiki/Formal_grammar
A. Soare.
> grammar of the html is identical ( via an isomorphism )
> to the lisp grammar: [...]
>
> Probably you mean "syntax" instead of "grammar".
>
> Html is lisp.
>
> You dignify html a lot more than it deserves!
>
> thi
>
>
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-23 13:21 A Soare
2008-06-23 13:51 ` tomas
` (3 more replies)
0 siblings, 4 replies; 22+ messages in thread
From: A Soare @ 2008-06-23 13:21 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: Emacs Dev [emacs-devel]
>
> Html is lisp.
>
> You dignify html a lot more than it deserves!
With the classical definition of HTML , yes.
With the new definition, they can be compared.
Alin.
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-23 13:21 A Soare
@ 2008-06-23 13:51 ` tomas
2008-06-23 16:56 ` Thomas Lord
` (2 subsequent siblings)
3 siblings, 0 replies; 22+ messages in thread
From: tomas @ 2008-06-23 13:51 UTC (permalink / raw)
To: A Soare; +Cc: Thien-Thi Nguyen, Emacs Dev [emacs-devel]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Mon, Jun 23, 2008 at 03:21:07PM +0200, A Soare wrote:
>
> >
> > Html is lisp.
> >
> > You dignify html a lot more than it deserves!
>
> With the classical definition of HTML , yes.
>
> With the new definition, they can be compared.
But only if you squint hard .-)
Of course, at the formal level you are right. But in the details, *ML
lose big time. See for example the quoting business in tag attributes,
for one of my pet peeves. Or white space handling.
Those folks must have been on acids. Bad ones.
(enough grumbling)
Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFIX6ppBcgs9XrR2kYRAhOgAJwKPF4Jqu48YjJpdEQk4Q/hWqLwIgCdGOTQ
/2NI5bfjHH4B3xgZ0q23SqY=
=WhHR
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-23 14:08 A Soare
2008-06-24 13:36 ` T. V. Raman
0 siblings, 1 reply; 22+ messages in thread
From: A Soare @ 2008-06-23 14:08 UTC (permalink / raw)
To: tomas; +Cc: Emacs Dev [emacs-devel]
>
> On Mon, Jun 23, 2008 at 03:21:07PM +0200, A Soare wrote:
> >
> > >
> > > Html is lisp.
> > >
> > > You dignify html a lot more than it deserves!
> >
> > With the classical definition of HTML , yes.
> >
> > With the new definition, they can be compared.
>
> But only if you squint hard .-)
>
> Of course, at the formal level you are right. But in the details, *ML
> lose big time. See for example the quoting business in tag attributes,
> for one of my pet peeves. Or white space handling.
>
> Those folks must have been on acids. Bad ones.
>
I realised that there are many cases to treat in order to correctly transform html -> lisp, and that is why I do not want to write a complete browser, just a minimum for what I need.
(enough grumbling)
Regards.
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-23 13:21 A Soare
2008-06-23 13:51 ` tomas
@ 2008-06-23 16:56 ` Thomas Lord
2008-06-23 17:04 ` Thien-Thi Nguyen
2008-06-23 20:07 ` Stephen J. Turnbull
3 siblings, 0 replies; 22+ messages in thread
From: Thomas Lord @ 2008-06-23 16:56 UTC (permalink / raw)
To: alinsoar; +Cc: Thien-Thi Nguyen, Emacs Dev [emacs-devel]
[-- Attachment #1: Type: text/plain, Size: 2573 bytes --]
A Soare wrote:
>> Html is lisp.
>>
>> You dignify html a lot more than it deserves!
>>
>
> With the classical definition of HTML , yes.
>
> With the new definition, they can be compared.
>
>
Are there any "structured data" languages that you know
of that can *not* be transformed to lisp in a similar way?
In other words, is HTML really special this way? Or
is this a specific instance of a generalized phenomenon?
Code is data and data is code.
An interesting point of history: one of the very first
lisp programs *ever* did symbolic differentiation.
It would take input like:
(exp x 2) # x squared
and produce output like:
(* x 2)
That program manipulated the math expressions just as
data. On the other hand, there is no reason you couldn't
have passed one of the expressions to EVAL, e.g., to get
a numeric value from it.
It would have been inconvenient, though, to try to write
the differentiation program by defining the function EXP
as a function that interpreted its arguments as sub-expressions
and returned the derivative of the overall expression.
(Of course, now some Schemer will be tempted to show
some Scheme macros that do symbolic differentiation but,
that's not the point.)
By analogy, for some uses it might be handy to interpret
HTML elements as procedure calls. For other uses, it is handy
to interpret them as lists. For still other uses, it is handy to
interpret them as tree objects (e.g., the DOM data structure).
As for a browser in Emacs: in spite of recent cracks (funny!) bout
"yet another Emacs in Javascript" -- Emacs in a browser might be
a lot easier than a browser in Emacs, judging by how Mozilla
works. E.g., Mozilla parses HTML and build a tree. That tree
acts a lot like an Emacs buffer in the sense that extension programs
can edit the tree abstractly and the display of that tree is automatically
updated. The standards for proper display of a web page are defined
in terms of these trees. By the time Emacs gained enough functionality
to handle such standards, it would resemble a small superset of the
functionality that already exists in Mozilla. Conversely, it is
probably a much smaller job to modify some of the key components
of Mozilla so that they provide all of the functionality of Emacs
buffers and display.
For the task you describe, though -- a desire not to make a full
browser but to be able to access a few simple web pages from Emacs --
of course Emacs can handily do that (and it sounds like you are getting
some stuff to start working, so congratulations!).
-t
[-- Attachment #2: Type: text/html, Size: 3226 bytes --]
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-23 13:21 A Soare
2008-06-23 13:51 ` tomas
2008-06-23 16:56 ` Thomas Lord
@ 2008-06-23 17:04 ` Thien-Thi Nguyen
2008-06-23 20:07 ` Stephen J. Turnbull
3 siblings, 0 replies; 22+ messages in thread
From: Thien-Thi Nguyen @ 2008-06-23 17:04 UTC (permalink / raw)
To: alinsoar; +Cc: Emacs Dev [emacs-devel]
() A Soare <alinsoar@voila.fr>
() Mon, 23 Jun 2008 15:21:07 +0200 (CEST)
With the classical definition of HTML , yes.
With the new definition, they can be compared.
What is the new definition? Where may i read about it?
thi
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-23 13:21 A Soare
` (2 preceding siblings ...)
2008-06-23 17:04 ` Thien-Thi Nguyen
@ 2008-06-23 20:07 ` Stephen J. Turnbull
3 siblings, 0 replies; 22+ messages in thread
From: Stephen J. Turnbull @ 2008-06-23 20:07 UTC (permalink / raw)
To: alinsoar; +Cc: Thien-Thi Nguyen, Emacs Dev [emacs-devel]
A Soare writes:
> With the new definition, they can be compared.
Well, as TTN and TL point out, the comparison is unfavorable to HTML,
which is highly unsuited to use as a programming language for a lot of
reasons.
In fact, IMO HTML is more comparable to prolog, as a declarative language.
The thing that has always fascinated me is just how powerful the
single idea that a programming language which has the same syntax for
executable code and data has been. Andrew Suffield once proposed that
Haskell *syntax* is Lisp without the Irritating Slew of Parentheses,
and it's an attractive way to think about it. Yet it's not a great
syntax for manipulation as data.
I think Lisp is eternal.
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-23 21:38 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-06-23 21:38 UTC (permalink / raw)
To: Thomas Lord; +Cc: Emacs Dev [emacs-devel]
In 2 words: what I meant is that every markup language can be defined
by a very simplified lisp evaluator, that accomplishes the simplest
possible rules, and that needs only 2-3 object types, depunding of the
markup language.
In Cnrtl I showed how to build such an evaluator for Html.
For the rest, I will answer your other questions tomorrow.
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-24 0:32 A Soare
2008-06-24 0:51 ` Stefan Monnier
2008-06-24 1:34 ` Thomas Lord
0 siblings, 2 replies; 22+ messages in thread
From: A Soare @ 2008-06-24 0:32 UTC (permalink / raw)
Cc: Emacs Dev [emacs-devel]
Thanks a lot for your reaction. You asked very well a question.
> A Soare wrote:
> >> Html is lisp.
> >>
> >> You dignify html a lot more than it deserves!
> >>
> >
> > With the classical definition of HTML , yes.
> >
> > With the new definition, they can be compared.
> >
> >
>
>
> Are there any "structured data" languages that you know
> of that can *not* be transformed to lisp in a similar way?
> In other words, is HTML really special this way? Or
> is this a specific instance of a generalized phenomenon?
>
What is behind of the phenomenon that I discovered here? Good
question...
The general principle discovered here is:
«The class of Markup languages is a subset of functional
languages. Every markup language is a very special case of
functional language.»
That says everything.
Html is defined as a very simplified functional language.
Xml is a simplified functional than html a little different of html.
Every markup language is a very simplified example of functional language.
To understand this principle, it is easy. Consider a functional
language like an implementation of a lambda-calculus, and
consider an implementation of a lambda-calculus as an evaluator.
Consider lisp evaluator as first example. To interpret html we need a
lisp evaluator in which the objects have just 2 types: strings and
list (in emacs Lisp the evaluator supports objects of 19 types (from
which 12 are Subtypes Lisp_Misc, because the evaluator allocated for
type object location just 3 bits)). (using these 2 types we can
express everything that html want to express). So HTML evaluator
embedded in LISP uses very little from the power of the lisp
evalutor. (imagine Edward Scissorhands working to create an html
evaluator from a lisp evaluator).
So I define html as a functional language defined by an evaluator with
2 types. It does not matter whether the evaluator supports closure
property or not and these kind of details. Imagine the tag (center 30
"string"). Do we need a closure property to execute it? What does it
have to do? Simple: It knows the width that is allocated for the
object that it must return, and it knows the value of the object. So
it will create a string in which this object is centered. It will
return:
" string "
(if the string was aligned on a single line) or something like:
" string1 "
" string2 "
" string3 "
" string4 "
if the string =
"
s1
s2
s3
s4. etc.
The same reasoning for XML. For XML we need 3 types (symbol + string +
list as I imagine).
All these markup languages are very simplified types of functional
languages. This is the genetal phenomenon. This is the new definition
of html. Is't an element of the class of functional languages.
Sorry for not having expressed myself clear from the first message.
So I proved that Html deserves so much! It's a simplified
lambda-calculus like Lisp!
A.S.
PS: for the rest of the message I will answer you later or tomorrow.
> Code is data and data is code.
>
> An interesting point of history: one of the very first
> lisp programs *ever* did symbolic differentiation.
> It would take input like:
>
> (exp x 2) # x squared
>
> and produce output like:
>
> (* x 2)
>
> That program manipulated the math expressions just as
> data. On the other hand, there is no reason you couldn't
> have passed one of the expressions to EVAL, e.g., to get
> a numeric value from it.
>
> It would have been inconvenient, though, to try to write
> the differentiation program by defining the function EXP
> as a function that interpreted its arguments as sub-expressions
> and returned the derivative of the overall expression.
> (Of course, now some Schemer will be tempted to show
> some Scheme macros that do symbolic differentiation but,
> that's not the point.)
>
> By analogy, for some uses it might be handy to interpret
> HTML elements as procedure calls. For other uses, it is handy
> to interpret them as lists. For still other uses, it is handy to
> interpret them as tree objects (e.g., the DOM data structure).
>
> As for a browser in Emacs: in spite of recent cracks (funny!) bout
> "yet another Emacs in Javascript" -- Emacs in a browser might be
> a lot easier than a browser in Emacs, judging by how Mozilla
> works. E.g., Mozilla parses HTML and build a tree. That tree
> acts a lot like an Emacs buffer in the sense that extension programs
> can edit the tree abstractly and the display of that tree is automatically
> updated. The standards for proper display of a web page are defined
> in terms of these trees. By the time Emacs gained enough functionality
> to handle such standards, it would resemble a small superset of the
> functionality that already exists in Mozilla. Conversely, it is
> probably a much smaller job to modify some of the key components
> of Mozilla so that they provide all of the functionality of Emacs
> buffers and display.
>
> For the task you describe, though -- a desire not to make a full
> browser but to be able to access a few simple web pages from Emacs --
> of course Emacs can handily do that (and it sounds like you are getting
> some stuff to start working, so congratulations!).
>
> -t
>
>
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-24 0:32 A Soare
@ 2008-06-24 0:51 ` Stefan Monnier
2008-06-24 1:34 ` Thomas Lord
1 sibling, 0 replies; 22+ messages in thread
From: Stefan Monnier @ 2008-06-24 0:51 UTC (permalink / raw)
To: alinsoar; +Cc: Emacs Dev [emacs-devel]
> «The class of Markup languages is a subset of functional languages.
> Every markup language is a very special case of functional language.»
In my book, in order for something to be called "functional language" it
needs some way to define/construct new functions.
But this is unrelated to Emacs, so please take this
discussion elsewhere.
It might be less off-topic on comp.lang.lisp, tho only slightly less so.
Stefan
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-24 0:32 A Soare
2008-06-24 0:51 ` Stefan Monnier
@ 2008-06-24 1:34 ` Thomas Lord
1 sibling, 0 replies; 22+ messages in thread
From: Thomas Lord @ 2008-06-24 1:34 UTC (permalink / raw)
To: alinsoar; +Cc: Emacs Dev [emacs-devel]
A Soare wrote:
>
> PS: for the rest of the message I will answer you later or tomorrow.
>
>
>
Take it easy on the emacs-devel list.
Part of what I've been hinting at is that there's a balance
here. Three hands:
On the first hand, you're rediscovering, not discovering.
Worth rediscovering and that's the best way to come to
understand it but...
On the second hand, you say you're building stuff: that's
to be encouraged, not discouraged. You are encouraged.
You are encouraged. You are encouraged.
On the third hand, this thread doesn't help much getting
the next version of Emacs out the door.
I think it is not so ridiculous to say that TTN, me, and now
Stephen are a little bit in "sitting around the campfire mode
swapping BS mode" with the three above pts in mind.
Might be time to turn in for the night on this one.
Sleep on it, so to speak.
-t
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-06-24 3:09 A Soare
2008-06-24 10:19 ` Thien-Thi Nguyen
0 siblings, 1 reply; 22+ messages in thread
From: A Soare @ 2008-06-24 3:09 UTC (permalink / raw)
To: Stefan Monnier, Thomas Lord; +Cc: Emacs Dev [emacs-devel]
> > «The class of Markup languages is a subset of functional languages.
> > Every markup language is a very special case of functional language.»
>
> In my book, in order for something to be called "functional language" it
> needs some way to define/construct new functions.
>
> But this is unrelated to Emacs, so please take this
> discussion elsewhere.
> It might be less off-topic on comp.lang.lisp, tho only slightly less so.
For you (in order to understand) I will rewrite in more details, what I have already said the my previous messages.
To make HTML a FUNCTIONAL LANGUAGE YOU MAKE SO:
1. Take *any* lisp (including scheme) evaluator. Supposing that you take the elisp evaluator.
2. Cut from the elisp evaluator all the types of objects , keeping STRING and LIST.
3. Cut *all* unsulseful functions (including all functions that use symbols like integers, because they cannot be evaluated any more); I will say you a few functions that are kept: DEFUN, DEFVAR, DEFCONST,FUNCALL_LAMBDA, APPLY, etc etc. to be able to CONSTRUCT NEW functions
4. In this moment you have A MINIMAL LISP EVALUATOR (that forms a *programming language* - functional programming language more precisely)
5. Start and define HTML TAGS as I did in cnrtl. You will be able to define ALL the tags with an evalutor that supports STRINGS ANS LISTS.
6. Now consider HTML code in LISP syntax (obtained from normal HTML by applying the isomorphism that I defined in my first message.
7. NOW YOU HAVE A FUNCTIONAL PROGRAMMING LANGUAGE THAT I CALL "HTML", because it accomplishes the html standard.
When you say "I REdescover, not DEScover", I have nothing to object, because I am not a professor to know all the culture in the domain. I am a little lisper.
But you did NOT AT ALL understand what I REdiscovered here, that is evident.
All my excuses for my "ridiculousness". I thought and I still think that I discovered a formula for the best emacs web browser that you do not know.
If you (you = Stefan Monnier + Thomas Lord) still have embarrassments, I will stay at your disposition to make you understand what I said. However, I do not want to continue this discussion.
Definition from "functional programming" in ecyclopedia:
The lambda calculus provides the model for functional programming.
Yes, I constructed a simplified lambda-calculus. I repeat.
Alin Soare.
PS: I agree that much of this discussion was a little off-topic, excuse me. I wanted just to convey a new idea of a browser that you do not have in emacs in this moment. But if it is forbidden...
____________________________________________________
En quelques secondes, créez-vous une autre adresse mail ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-24 3:09 A Soare
@ 2008-06-24 10:19 ` Thien-Thi Nguyen
0 siblings, 0 replies; 22+ messages in thread
From: Thien-Thi Nguyen @ 2008-06-24 10:19 UTC (permalink / raw)
To: alinsoar; +Cc: Emacs Dev [emacs-devel]
() A Soare <alinsoar@voila.fr>
() Tue, 24 Jun 2008 05:09:49 +0200 (CEST)
But you did NOT AT ALL understand
what I REdiscovered here, that is evident.
Sometimes what we know of others is more than what we know of ourselves.
I thought and I still think that I discovered a formula for the
best emacs web browser that you do not know.
Sometimes what we don't know of others is more than what we don't
know {of} ourselves.
But if it is forbidden...
I think if you are comfortable hacking C, you would find
it enjoyable to compare/contrast/integrate your program
with the Emacs function `parse-partial-sexp'. That is
another way to sharingly appreciate isomorphisms. I for
one would be interested in hearing about these explorations.
I'll bow out of this thread now.
thi
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-23 14:08 A Soare
@ 2008-06-24 13:36 ` T. V. Raman
2008-06-24 14:41 ` joakim
0 siblings, 1 reply; 22+ messages in thread
From: T. V. Raman @ 2008-06-24 13:36 UTC (permalink / raw)
To: alinsoar; +Cc: tomas, emacs-devel
A simpler way to do this is to actually hand off the grungy
details of dealing with broken HTML to existing software, and get
back something clean.
Here are some options:
0) libxslt from the Gnome project. It can clean up bad HTML,
turn it into something well formed, and give you something easy
to parse and handle.
1) Connecting to a browser --- at present I use a Firefox
extension called mozrepl to talk to Firefox over a socket from
Emacs. You can send JavaScript to Firefox, and get back relevents
portions of the DOM back as cleaned up HTML.
2) It might be worthwhile to build something similar to the
above, but with Webkit running headless -- since over time that
would give a lighter weight solution.
A truly ambitious thing to try would be to link in the HTML
parser/renderer bits of webkit into Emacs to provide a truly
integrated experience.
>>>>> "A" == A Soare <alinsoar@voila.fr> writes:
>> On Mon, Jun 23, 2008 at 03:21:07PM +0200, A Soare wrote:
>> >
>> > >
>> > > Html is lisp.
>> > >
>> > > You dignify html a lot more than it deserves!
>> >
>> > With the classical definition of HTML , yes.
>> >
>> > With the new definition, they can be compared.
>>
>> But only if you squint hard .-)
>>
>> Of course, at the formal level you are right. But in the
>> details, *ML lose big time. See for example the quoting
>> business in tag attributes, for one of my pet peeves. Or
>> white space handling.
>>
>> Those folks must have been on acids. Bad ones.
>>
A>
I realised that there are many cases to treat in order to
A> correctly transform html -> lisp, and that is why I do not
A> want to write a complete browser, just a minimum for what
A> I need.
A>
A> (enough grumbling)
A>
A>
A> Regards.
A>
A>
A>
A>
A> ____________________________________________________
A>
A> En quelques secondes, créez-vous une autre adresse mail !
A> http://mail.voila.fr
A>
A>
A>
--
Best Regards,
--raman
Email: raman@users.sf.net
WWW: http://emacspeak.sf.net/raman/
AIM: emacspeak GTalk: tv.raman.tv@gmail.com
PGP: http://emacspeak.sf.net/raman/raman-almaden.asc
Google: tv+raman
IRC: irc://irc.freenode.net/#emacs
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
2008-06-24 13:36 ` T. V. Raman
@ 2008-06-24 14:41 ` joakim
0 siblings, 0 replies; 22+ messages in thread
From: joakim @ 2008-06-24 14:41 UTC (permalink / raw)
To: raman; +Cc: alinsoar, tomas, emacs-devel
"T. V. Raman" <raman@users.sourceforge.net> writes:
> A truly ambitious thing to try would be to link in the HTML
> parser/renderer bits of webkit into Emacs to provide a truly
> integrated experience.
This is should be doable. I have a patch to enable embedding of gtk
widgets in emacs buffers. It's work in progress, but I can embed emacs
in emacs already, and other stuff.
>>>>>> "A" == A Soare <alinsoar@voila.fr> writes:
> >> On Mon, Jun 23, 2008 at 03:21:07PM +0200, A Soare wrote:
> >> >
> >> > >
> >> > > Html is lisp.
> >> > >
> >> > > You dignify html a lot more than it deserves!
> >> >
> >> > With the classical definition of HTML , yes.
> >> >
> >> > With the new definition, they can be compared.
> >>
> >> But only if you squint hard .-)
> >>
> >> Of course, at the formal level you are right. But in the
> >> details, *ML lose big time. See for example the quoting
> >> business in tag attributes, for one of my pet peeves. Or
> >> white space handling.
> >>
> >> Those folks must have been on acids. Bad ones.
> >>
> A>
> I realised that there are many cases to treat in order to
> A> correctly transform html -> lisp, and that is why I do not
> A> want to write a complete browser, just a minimum for what
> A> I need.
> A>
> A> (enough grumbling)
> A>
> A>
> A> Regards.
> A>
> A>
> A>
> A>
> A> ____________________________________________________
> A>
> A> En quelques secondes, créez-vous une autre adresse mail !
> A> http://mail.voila.fr
> A>
> A>
> A>
--
Joakim Verona
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: Embedding Html in Lisp
@ 2008-07-01 19:05 A Soare
0 siblings, 0 replies; 22+ messages in thread
From: A Soare @ 2008-07-01 19:05 UTC (permalink / raw)
To: Thien-Thi Nguyen; +Cc: Emacs Dev [emacs-devel]
> But you did NOT AT ALL understand
> what I REdiscovered here, that is evident.
>
> Sometimes what we know of others is more than what we know of ourselves.
>
True!
I discovered in the meantime that XML was considered into a programming language here:
http://www.cs.aau.dk/~normark/laml/
or to INRIA:
http://hop.inria.fr/
What I tried to do was impossible (it's true that we cannot do from html a full programming language). But what I did for me works for me better than Mozilla or webkit!
> I think if you are comfortable hacking C, you would find
> it enjoyable to compare/contrast/integrate your program
> with the Emacs function `parse-partial-sexp'. That is
> another way to sharingly appreciate isomorphisms. I for
> one would be interested in hearing about these explorations.
>
Then you could consult the indentation of lisp code, because they are similar.
> I'll bow out of this thread now.
No problem! I give you the right to use my code if you like it.
Alin Soare
____________________________________________________
Sur le mail Voila, vous pouvez personnaliser l’anti-spam ! http://mail.voila.fr
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2008-07-01 19:05 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-23 21:38 Embedding Html in Lisp A Soare
-- strict thread matches above, loose matches on Subject: below --
2008-07-01 19:05 A Soare
2008-06-24 3:09 A Soare
2008-06-24 10:19 ` Thien-Thi Nguyen
2008-06-24 0:32 A Soare
2008-06-24 0:51 ` Stefan Monnier
2008-06-24 1:34 ` Thomas Lord
2008-06-23 14:08 A Soare
2008-06-24 13:36 ` T. V. Raman
2008-06-24 14:41 ` joakim
2008-06-23 13:21 A Soare
2008-06-23 13:51 ` tomas
2008-06-23 16:56 ` Thomas Lord
2008-06-23 17:04 ` Thien-Thi Nguyen
2008-06-23 20:07 ` Stephen J. Turnbull
2008-06-23 12:23 A Soare
2008-06-23 11:49 A Soare
2008-06-22 22:27 A Soare
2008-06-22 20:56 A Soare
2008-06-22 21:29 ` Drew Adams
2008-06-23 8:33 ` Thien-Thi Nguyen
2008-06-22 20:53 Embedding HTML " A Soare
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).