Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions TeXmacs/plugins/account/data/copy_to_zhihu.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
\begin{document}
很抱歉,复制到知乎功能为 Liii STEM 专属。\
详情请见 \url{https://liiistem.cn/} 注册即送7天会员!\
已为您按照纯文本格式复制内容。
\end{document}
59 changes: 59 additions & 0 deletions TeXmacs/plugins/zhihu/progs/data/zhihu.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; MODULE : zhihu.scm
;; DESCRIPTION : zhihu data format (export snippet)
;; COPYRIGHT : (C) 2026 Liii Network
;;
;; This software falls under the GNU general public license version 3 or later.
;; It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
;; in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(texmacs-module (data zhihu)
(:use (kernel gui menu-widget)
(utils edit selections)))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Zhihu format definition
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(define-format zhihu
(:name "知乎")
(:suffix "zhihu"))

(define (tree->document-stree t)
(let ((st (tree->stree t)))
(if (and (pair? st) (eq? (car st) 'document))
st
`(document ,st))))

(define (zhihu-tip-tree)
(let* ((latex-code (string-load (unix->url "$TEXMACS_PATH/plugins/account/data/copy_to_zhihu.tex")))
(parsed-latex (parse-latex latex-code)))
(latex->texmacs parsed-latex)))

(define (zhihu-tree-with-tip t)
(let* ((content-st (tree->document-stree t))
(tip-st (tree->document-stree (zhihu-tip-tree)))
(merged-st (cons 'document
(append (cdr content-st)
(list "")
(cdr tip-st)))))
(stree->tree merged-st)))

(tm-define (texmacs-tree->zhihu-snippet t)
(:synopsis "Export TeXmacs snippet as plain text and append zhihu tip")
(texmacs->generic (zhihu-tree-with-tip t) "verbatim-snippet"))

(converter texmacs-tree zhihu-snippet
(:function texmacs-tree->zhihu-snippet))

;; Keep "Copy to -> Zhihu" as structured clipboard data (like Ctrl+C),
;; while appending the zhihu tip content at the end of the copied tree.
(tm-define (clipboard-copy-export format which)
(:require (== format "zhihu"))
(let ((temp (clipboard-get-export)))
(clipboard-set-export "default")
(clipboard-set which (zhihu-tree-with-tip (selection-tree)))
(clipboard-set-export temp)))
1 change: 1 addition & 0 deletions TeXmacs/progs/init-research.scm
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@
(lazy-format (data tmu) tmu)
(lazy-format (data docx) docx)
(lazy-format (data html) html)
(lazy-format (data zhihu) zhihu)
(lazy-define (convert images tmimage)
export-selection-as-graphics clipboard-copy-image)
(lazy-define (convert rewrite init-rewrite) texmacs->code texmacs->verbatim)
Expand Down
9 changes: 9 additions & 0 deletions devel/201_99.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# [201_99] 社区版选中内容复制到知乎添加提示信息

## 如何测试
- 选中任意内容,鼠标右键`复制到`->`知乎`
- 在`mogan`内粘贴,内容保持不变,在最下面添加提示信息
- 在知乎内粘贴和`Ctrl+c`逻辑保持一致,纯文本复制


## 2026/03/19 社区版选中内容复制到知乎添加提示信息