-
-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
103 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,30 @@ | ||
(defpackage :lem-markdown-mode/internal | ||
(:use :cl) | ||
(:export :on-save | ||
:on-kill)) | ||
:on-kill | ||
:on-change | ||
:preview | ||
:on-save-default | ||
:on-kill-default | ||
:on-change-default | ||
:preview-default)) | ||
(in-package :lem-markdown-mode/internal) | ||
|
||
(defgeneric on-save (buffer)) | ||
(defgeneric on-kill (buffer)) | ||
(defparameter *view-type* :html-buffer) | ||
|
||
(defgeneric on-save (buffer view-type)) | ||
(defgeneric on-kill (buffer view-type)) | ||
(defgeneric on-change (buffer view-type)) | ||
(defgeneric preview (buffer view-type)) | ||
|
||
(defun on-save-default (buffer) | ||
(on-save buffer *view-type*)) | ||
|
||
(defun on-kill-default (buffer) | ||
(on-kill buffer *view-type*)) | ||
|
||
(defun on-change-default (buffer) | ||
(on-change buffer *view-type*)) | ||
|
||
(defun preview-default (buffer) | ||
(preview buffer *view-type*)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
(uiop:define-package :lem-markdown-mode/preview/html-buffer | ||
(:use :cl :lem) | ||
(:import-from :lem-markdown-mode/preview/preview | ||
:render)) | ||
(in-package :lem-markdown-mode/preview/html-buffer) | ||
|
||
(defun preview-buffer-name (buffer) | ||
(format nil | ||
"*Markdown Preview ~A*" | ||
(buffer-name buffer))) | ||
|
||
(defmethod lem-markdown-mode/internal:preview (buffer (view-type (eql :html-buffer))) | ||
(let* ((html (render (buffer-text buffer))) | ||
(html-buffer (lem:make-html-buffer (preview-buffer-name buffer) | ||
html))) | ||
(pop-to-buffer html-buffer))) | ||
|
||
(defmethod lem-markdown-mode/internal:on-save (buffer (view-type (eql :html-buffer))) | ||
(lem-markdown-mode/internal:preview buffer :html-buffer)) | ||
|
||
(defmethod lem-markdown-mode/internal:on-kill (buffer (view-type (eql :html-buffer))) | ||
) | ||
|
||
(defmethod lem-markdown-mode/internal:on-change (buffer (view-type (eql :html-buffer))) | ||
(when (get-buffer (preview-buffer-name buffer)) | ||
(lem-markdown-mode/internal:preview buffer :html-buffer))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
(uiop:define-package :lem-markdown-mode/preview/preview | ||
(:use :cl :lem)) | ||
(in-package :lem-markdown-mode/preview/preview) | ||
|
||
(define-command markdown-preview () () | ||
(lem-markdown-mode/internal:preview (current-buffer) :html-buffer)) | ||
|
||
(defun render (string) | ||
(let ((3bmd-code-blocks:*code-blocks* t)) | ||
(with-output-to-string (stream) | ||
(3bmd:parse-string-and-print-to-stream string stream)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(in-package :lem-core) | ||
|
||
(defclass html-buffer (text-buffer) | ||
((html :initarg :html | ||
:reader html-buffer-html))) | ||
|
||
(defun make-html-buffer (buffer-name html) | ||
(let ((buffer (make-buffer buffer-name))) | ||
(change-class buffer 'html-buffer :html html) | ||
buffer)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters