diff --git a/TeXmacs/plugins/account/data/copy_to_zhihu.tex b/TeXmacs/plugins/account/data/copy_to_zhihu.tex new file mode 100644 index 0000000000..a4d3ed2e12 --- /dev/null +++ b/TeXmacs/plugins/account/data/copy_to_zhihu.tex @@ -0,0 +1,5 @@ +\begin{document} +很抱歉,复制到知乎功能为 Liii STEM 专属。\ +详情请见 \url{https://liiistem.cn/} 注册即送7天会员!\ +已为您按照纯文本格式复制内容。 +\end{document} diff --git a/TeXmacs/plugins/zhihu/progs/data/zhihu.scm b/TeXmacs/plugins/zhihu/progs/data/zhihu.scm new file mode 100644 index 0000000000..e7f05fc1f0 --- /dev/null +++ b/TeXmacs/plugins/zhihu/progs/data/zhihu.scm @@ -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 . +;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(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))) diff --git a/TeXmacs/progs/init-research.scm b/TeXmacs/progs/init-research.scm index 246428e718..679bad9b2e 100644 --- a/TeXmacs/progs/init-research.scm +++ b/TeXmacs/progs/init-research.scm @@ -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) diff --git a/devel/201_99.md b/devel/201_99.md new file mode 100644 index 0000000000..70e545d790 --- /dev/null +++ b/devel/201_99.md @@ -0,0 +1,9 @@ +# [201_99] 社区版选中内容复制到知乎添加提示信息 + +## 如何测试 +- 选中任意内容,鼠标右键`复制到`->`知乎` +- 在`mogan`内粘贴,内容保持不变,在最下面添加提示信息 +- 在知乎内粘贴和`Ctrl+c`逻辑保持一致,纯文本复制 + + +## 2026/03/19 社区版选中内容复制到知乎添加提示信息 \ No newline at end of file