Skip to content

Commit

Permalink
improve lisp and html-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kchanqvq committed Nov 27, 2024
1 parent 0fc6c3b commit 49c6e1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions modes/html-doc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@
(defmethod on-node-setup progn ((buffer html-doc-mode) (node text-node))
(with-post-command (node 'parent)
(let ((parent (parent node)))
(when (tag-name-p parent "body")
(when (allow-block-element-p parent)
(let ((new-node (make-element "p")))
(insert-nodes (text-pos node 0) new-node)
(move-nodes (text-pos node 0) (next-sibling node)
(end-pos new-node)))))))

(defun allow-block-element-p (parent)
(member (tag-name parent)
'("div" "li" "article" "section" "main" "aside" "header" "footer" "nav" "td" "body")
'("div" "li" "article" "section" "main" "aside" "header" "footer" "nav" "body")
:test 'equal))

(defun check-valid-parent (parent child-tag)
Expand All @@ -69,7 +69,7 @@
(define-command open-paragraph
:mode html-doc-mode (&optional (marker (focus)))
(let ((pos (resolve-marker marker)))
(if (tag-name-p (node-containing pos) "body")
(if (allow-block-element-p (node-containing pos))
(let ((new-node (make-element "p")))
(insert-nodes pos new-node)
(setf (pos marker) (pos-down new-node)))
Expand Down
4 changes: 2 additions & 2 deletions modes/lisp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
*sexp-node-keymap*)))

(defmethod on-node-setup progn ((buffer lisp-mode) (node element))
(set-attribute-function node "operator" 'compute-operator)
(with-post-command (node 'parent)
(let ((parent (parent node)))
(cond
Expand All @@ -129,7 +128,8 @@
(with-output-to-string (s)
(write-dom-aux buffer node s)))))))
(when (symbol-node-p node)
(set-attribute-function node "symbol-type" 'compute-symbol-type))
(set-attribute-function node "symbol-type" 'compute-symbol-type)
(set-attribute-function node "operator" 'compute-operator))
(when (class-p node "comment" "string")
(setf (attribute node 'keymap) *plaintext-node-keymap*))
(when (class-p node "object")
Expand Down

0 comments on commit 49c6e1c

Please sign in to comment.