Skip to content

使用 HTML 块时建议使用 <div> 包裹 HTML 代码 #5732

@a15355447898a

Description

@a15355447898a
Contributor

该问题是否已经被报告过了? Is there an existing issue for this?

  • 我已经搜索了 Issues,没有发现类似问题
    I have searched the existing issues

描述问题 Describe the problem

建立了一个html块,其中包含

<pre style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;">/etc/mkinitcpio.conf</pre>
<pre style="margin-top: 0; border-top-style:dashed; padding-top: 0.8em;">HOOKS=(base <b>udev</b> ... block <b>lvm2</b> filesystems)</pre>

在重启SiYuan后发现只剩下了

<pre style="margin-bottom: 0; border-bottom:none; padding-bottom:0.8em;">/etc/mkinitcpio.conf</pre>

期待的结果 Expected result

应该可以完整保存的啊?

截屏或者录屏演示 Screenshot or screen recording presentation

https://www.aliyundrive.com/s/7d9vqWUiwEY

版本环境 Version environment

- Version: 2.1.9
- Operating System: Windows11
- Browser (if used):

日志文件 Log file

siyuan.log

更多信息 More information

另外,编写完这个html块后(不退出),按ctrl+z,会出现
image

Activity

changed the title [-]编写了一个html块,关闭再重新打开SiYuan后发现其中的代码丢失了一部分[/-] [+]HTML 块中包含多个 `<pre>` 时只能保存第一个[/+] on Aug 27, 2022
added this to the 2.1.10 milestone on Aug 27, 2022
88250

88250 commented on Aug 27, 2022

@88250
Member

这个问题主要是因为 Markdown 语法解析生成了两个 HTML 块:

image

如果用 <div> 包裹 <pre> 的话就是一个 HTML 块:

image

对于前面不包裹的情况,会弹出提示信息建议用户使用 <div> 包裹 HTML 代码。

added a commit that references this issue on Aug 27, 2022
changed the title [-]HTML 块中包含多个 `<pre>` 时只能保存第一个[/-] [+]使用 HTML 块时建议使用 `<div>` 包裹 HTML 代码[/+] on Aug 28, 2022
added a commit that references this issue on Aug 28, 2022
qiuzhiqian

qiuzhiqian commented on Dec 2, 2022

@qiuzhiqian

你好,请问该问题是还存在吗,我再思源2.5.2版本上面,使用html块插入html文本,预览是可以生效的,然后关掉这个文档页面,重新打开页面后,html就变成纯文本了。
截图_选择区域_20221202103327

可以正常预览
截图_选择区域_20221202103344

重新关闭这个页面后重新打开
截图_选择区域_20221202103406

qiuzhiqian

qiuzhiqian commented on Dec 2, 2022

@qiuzhiqian

不太确定是不是我的使用方式不正确

88250

88250 commented on Dec 2, 2022

@88250
Member

@qiuzhiqian 需要使用 div 包裹

qiuzhiqian

qiuzhiqian commented on Dec 2, 2022

@qiuzhiqian

@88250 嗯,我的理解,对于一个普通用户而言,如果没有特殊提现,他一般是不知道需要包裹一个div的,那么这个div是否应该由软件来自动处理一下比较好。而且我上面的这个例子中,好像确实没有看到任何提示说需要用div包裹。关键是不重启的时候还预览生效了,也并没有包任何错误

88250

88250 commented on Dec 2, 2022

@88250
Member

目前会提示多个 HTML 块没有 div 包裹时数据丢失的情况:

image

如果是行级元素的话没有提示,这个我们考虑下是否能像你说的,自动通过 div 包裹。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Vanessa219@qiuzhiqian@a15355447898a

      Issue actions

        使用 HTML 块时建议使用 `<div>` 包裹 HTML 代码 · Issue #5732 · siyuan-note/siyuan