Git Product home page Git Product logo

Comments (12)

allrobot avatar allrobot commented on May 27, 2024

3.0.13依旧是复制网页元素,截图:

SiYuan_UUIPx7IUGN

如果是单单是复制<span class="pre">capture_stdout=True,</span><span> </span><span class="pre">stderr=subprocess.STDOUT</span>到剪切板就没问题,如果网页元素周围有文本时就不行了

不知道你用的是什么解析剪切板的富文本信息,剪切板都是HTML富文本形式,操作截图:

chrome_nTHWUiZK8W

import win32clipboard


def GetAvailableFormats():
    """
    Return a possibly empty list of formats available on the clipboard
    返回剪切板可能有的一些格式
    """
    formats = []
    try:
        win32clipboard.OpenClipboard(0)
        cf = win32clipboard.EnumClipboardFormats(0)
        while (cf != 0):
            formats.append(cf)
            cf = win32clipboard.EnumClipboardFormats(cf)
    finally:
        win32clipboard.CloseClipboard()

    return formats

# CF_HTML=49433
CF_HTML = win32clipboard.RegisterClipboardFormat("HTML Format")

if CF_HTML in GetAvailableFormats():
    win32clipboard.OpenClipboard(0)
    src = win32clipboard.GetClipboardData(CF_HTML)
    src = src.decode("UTF-8")
    print(src)
else:
    print("当前剪切板没有富文本内容")

完整的剪切板内容输出:

C:\ProgramData\anaconda3\envs\python311\python.exe C:\Users\Administrator\Personal_scripts\pythonProject\temp.py 
Version:0.9
StartHTML:0000000200
EndHTML:0000004248
StartFragment:0000000236
EndFragment:0000004212
SourceURL:https://trio.readthedocs.io/en/stable/reference-io.html#asynchronous-filesystem-i-o
<html>
<body>
<!--StartFragment--><span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">如果要同时捕获 stdout 和 stderr,但要按打印顺序将它们混合在一起,请使用:<span> </span></span><code class="docutils literal notranslate" data-immersive-translate-walked="a926668a-d38b-4e1e-824c-535ff2a6205f" style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 12px; white-space: normal; max-width: 100%; background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); padding: 2px 5px; color: rgb(34, 34, 34) !important; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="pre" style="box-sizing: border-box;">capture_stdout=True,</span><span> </span><span class="pre" style="box-sizing: border-box;">stderr=subprocess.STDOUT</span></code><span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>。这会将子项的 stderr 引导到其 stdout,因此组合输出将在属性中<span> </span></span><code class="xref py py-obj docutils literal notranslate" data-immersive-translate-walked="a926668a-d38b-4e1e-824c-535ff2a6205f" style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 12px; white-space: normal; max-width: 100%; background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); padding: 2px 5px; color: rgb(34, 34, 34) !important; overflow-x: auto; font-weight: 700; overflow-wrap: normal; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="pre" style="box-sizing: border-box;">stdout</span></code><span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>可用</span><!--EndFragment-->
</body>
</html> 

进程已结束,退出代码为 0

表格在代码其中:

<span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">如果要同时捕获 stdout 和 stderr,但要按打印顺序将它们混合在一起,请使用:<span> </span></span><code class="docutils literal notranslate" data-immersive-translate-walked="a926668a-d38b-4e1e-824c-535ff2a6205f" style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 12px; white-space: normal; max-width: 100%; background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); padding: 2px 5px; color: rgb(34, 34, 34) !important; overflow-x: auto; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="pre" style="box-sizing: border-box;">capture_stdout=True,</span><span> </span><span class="pre" style="box-sizing: border-box;">stderr=subprocess.STDOUT</span></code><span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>。这会将子项的 stderr 引导到其 stdout,因此组合输出将在属性中<span> </span></span><code class="xref py py-obj docutils literal notranslate" data-immersive-translate-walked="a926668a-d38b-4e1e-824c-535ff2a6205f" style="box-sizing: border-box; font-family: SFMono-Regular, Menlo, Monaco, Consolas, &quot;Liberation Mono&quot;, &quot;Courier New&quot;, Courier, monospace; font-size: 12px; white-space: normal; max-width: 100%; background: rgb(255, 255, 255); border: 1px solid rgb(225, 228, 229); padding: 2px 5px; color: rgb(34, 34, 34) !important; overflow-x: auto; font-weight: 700; overflow-wrap: normal; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><span class="pre" style="box-sizing: border-box;">stdout</span></code><span style="color: rgb(64, 64, 64); font-family: Lato, proxima-nova, &quot;Helvetica Neue&quot;, Arial, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(252, 252, 252); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;"><span> </span>可用</span>

table代码直接粘贴到Github的MD编辑器就显示成表格:
如果要同时捕获 stdout 和 stderr,但要按打印顺序将它们混合在一起,请使用: capture_stdout=True, stderr=subprocess.STDOUT 。这会将子项的 stderr 引导到其 stdout,因此组合输出将在属性中 stdout 可用

操作截图:

chrome_PDxkLlHwtQ

善用富文本,MD写作笔记中的富文本地位很高

from siyuan.

88250 avatar 88250 commented on May 27, 2024

我这里测试正文中提到的网页 DOM 结构已经没有问题:

issue.webm

其他网页的话麻烦单独提 issue 进行改进,谢谢。

from siyuan.

allrobot avatar allrobot commented on May 27, 2024

其他网页的话麻烦单独提 issue 进行改进,谢谢。

SiYuan_4K6ww92ITK

from siyuan.

88250 avatar 88250 commented on May 27, 2024

收到,这种情况下个版本改进,谢谢。

from siyuan.

allrobot avatar allrobot commented on May 27, 2024

是否有考虑:

  1. 每个块/页面的添加纯文本模式即时预览模式?(每个块当成单独的编辑框,类似Issue编辑某个评论就弹出编辑框)
  2. 每个块支持HTML元素展示,以及更丰富的MD语法支持

Github的Issue编辑框的WritePreview按钮,粘贴HTML元素后,切为Preview模式就能立刻显示,Github的编辑框特性是挺实用的,优点:

  1. 兼容HTML元素,任何页面就能展示丰富的HTML元素,如不满意可切换Write模式重新编辑HTML文本
  2. 更多的MD语法支持,例如引用中的引用颜色模型等等

其它:
创建表格,若编辑标点在表格末尾,连按Enter几次没什么反应,不是很符合用户直觉,Enter应该改成连按2次就退出表格切换到下一个块(相当于ctrl+shift+A

from siyuan.

88250 avatar 88250 commented on May 27, 2024

思源笔记的编辑器不是 Markdown 编辑器,所以不考虑源码编辑模式。

@Vanessa219 表格最后一行 Enter 跳出创建新块考虑一下。

from siyuan.

allrobot avatar allrobot commented on May 27, 2024

思源笔记的编辑器不是 Markdown 编辑器,所以不考虑源码编辑模式。

自研编辑器?那更多的MD语法还考虑支持吗?😬

from siyuan.

88250 avatar 88250 commented on May 27, 2024

from siyuan.

allrobot avatar allrobot commented on May 27, 2024

SiYuan_m5OfpFHpwt

复制Github的引用链接出错,无法转为[subject:matches-attr(arg)](https://github.com/siyuan-note/siyuan/issues/11281)

链接:https://github.com/fang5566/uBlock/wiki/%E8%BF%87%E7%A8%8B%E5%BC%8F%E4%BF%AE%E9%A5%B0%E8%A7%84%E5%88%99

from siyuan.

88250 avatar 88250 commented on May 27, 2024

@allrobot

image

这个 a 标签的锚文本是个 svg,编辑器进行处理,所以导致锚文本为空,从而无法转换渲染为正常的超链接:

image

下个版本会改进为直接丢弃锚文本为空的超链接元素。

from siyuan.

allrobot avatar allrobot commented on May 27, 2024

这时候就体现富文本HTML的优势了,放到Github编辑框能自动显示为合适的格式,siyuan应该添加富文本/HTML支持,这样无论下次剪切/复制什么内容,siyuan就直接读取HTML转为合适的格式

SiYuan_x3BnSQ8sH4

剪切板的问题陆陆续续遇到了好几次,这次解决了,但下次又双叒叕遇到了咋办😂

from siyuan.

88250 avatar 88250 commented on May 27, 2024

from siyuan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.