Skip to content

Preview mode copy to WeChat MP supports lists with more than two levels #11276

Closed
@Achuan-2

Description

@Achuan-2
Member

预览模式复制到微信公众号支持超过两级的列表

In what scenarios do you need this feature?

预览模式复制到微信公众号,列表最多正常渲染两级
思源笔记的预览模式
Clip_2024-05-06_21-56-00
粘贴微信公众号

Clip_2024-05-06_21-55-53

Describe the optimal solution

目前的渲染是,次级的列表会包含在<li>中,而微信则是需要次级列表和<li>同级。
目前复制的多级列表html结构为:

<ul>
	<li>
		<ul>
			<li>
				<ul></ul>			
			</li>
		</ul>
	</li>
</ul>

微信公众号需要正常渲染的预期如下:

<ul>
	<li></li>
	<ul>
		<li></li>
		<ul>
               </ul>
	</ul>
</ul>

Describe the candidate solution

Other information

No response

Activity

changed the title [-]预览模式复制到微信支持超过三级的列表[/-] [+]预览模式复制到微信公众号支持超过三级的列表[/+] on May 6, 2024
changed the title [-]预览模式复制到微信公众号支持超过三级的列表[/-] [+]预览模式复制到微信公众号支持超过两级的列表[/+] on May 6, 2024
Achuan-2

Achuan-2 commented on May 13, 2024

@Achuan-2
MemberAuthor

可参考代码:doocs/md@b3a52ba

Achuan-2

Achuan-2 commented on Nov 14, 2024

@Achuan-2
MemberAuthor

https://ld246.com/article/1731553411638
处理代码

function convertListToWechat() {
    // Select all <ul> and <ol> elements
    const lists = document.querySelectorAll('ul, ol');

    lists.forEach(list => {
        // Get all <li> children of the current list
        const items = Array.from(list.children);

        items.forEach(item => {
            // Check if the <li> has a nested <ul> or <ol> as its direct child
            const nestedList = item.querySelector('ul, ol');
            if (nestedList) {
                // Move the nested list to be a sibling of the current <li>
                item.parentNode.insertBefore(nestedList, item.nextSibling);
            }
        });
    });
}

// Run the function to adjust the list structure
convertListToWechat();

多级列表举例

  • 多巴胺

    1. 基本概念

      • 多巴胺是一种神经递质,属于儿茶酚胺和苯乙胺家族。
      • 它在大脑和身体中扮演着多种角色,尤其是在奖励、动机和愉悦感的调节中。
      • 化学式为$C_8H_{11}NO_2$,其结构中包含一个苯环和一个胺基。
    2. 生理功能

      • 奖励与动机

        • 多巴胺在大脑的奖励系统中起关键作用,影响动机和愉悦感。
        • 它的释放与愉快的体验和行为强化有关。
      • 运动控制

        • 在中脑的黑质区,多巴胺调节运动功能。
        • 多巴胺缺乏与帕金森病有关,导致运动障碍。
      • 情绪与认知

        • 多巴胺影响情绪调节和认知功能。
        • 其失衡可能与精神疾病如抑郁症和精神分裂症有关。
    3. 合成与代谢

      • 合成

        • 多巴胺由氨基酸酪氨酸通过一系列酶促反应合成。
        • 关键步骤包括酪氨酸羟化酶催化生成左旋多巴(L-DOPA),然后由多巴脱羧酶转化为多巴胺。
      • 代谢

        • 多巴胺通过单胺氧化酶(MAO)和儿茶酚-O-甲基转移酶(COMT)代谢。
        • 代谢产物包括高香草酸(HVA),可通过尿液排出。
    4. 临床相关性

      • 帕金森病

        • 由于黑质区多巴胺神经元的退化,导致运动功能障碍。
        • 治疗通常涉及多巴胺替代疗法,如左旋多巴。
      • 精神疾病

        • 精神分裂症与多巴胺系统的过度活跃有关。
        • 抗精神病药物通常通过阻断多巴胺受体来发挥作用。
      • 成瘾

        • 多巴胺在成瘾行为中起重要作用,许多药物通过增加多巴胺释放或阻止其再摄取来产生愉悦感。
        • 成瘾治疗可能涉及调节多巴胺系统的药物。

修改前,发布到微信公众号的样式
image
修改后,发到公众号的样式
image

TCOTC

TCOTC commented on Dec 21, 2024

@TCOTC
Contributor

相关反馈:

Screenshot_2024-12-21-15-29-33-92_9d26c6446fd7bb8e41d99b6262b17def.jpg

Achuan-2

Achuan-2 commented on Dec 21, 2024

@Achuan-2
MemberAuthor

另外提示下,微信公众号部分用户被灰度更新了,新版的代码块和引述块思源笔记直接粘贴,格式会丢失,要切换旧版,需要链接末尾添加&mpeditor=0

added this to the 3.1.29 milestone on Apr 18, 2025
Vanessa219

Vanessa219 commented on Apr 21, 2025

@Vanessa219
Member

如果没有被灰度更新的要怎么才能测试代码块和引述呢?

added a commit that references this issue on Apr 21, 2025
Achuan-2

Achuan-2 commented on Apr 21, 2025

@Achuan-2
MemberAuthor

如果没有被灰度更新的要怎么才能测试代码块和引述呢?

代码块目前没问题了
引述块格式也没问题,目前主要的问题是新版微信编辑器限制引述块字数不超过300字

Image

可以试试编辑器末尾添加&mpeditor=1(不确定能不能进入新版编辑器)

Achuan-2

Achuan-2 commented on Apr 21, 2025

@Achuan-2
MemberAuthor

@Vanessa219
既然改进了列表,有空的时候也把公式也改进了吧,我之前已经给了方案了

#12571

Vanessa219

Vanessa219 commented on Apr 22, 2025

@Vanessa219
Member

不知道行不行,都没有问题。

changed the title [-]预览模式复制到微信公众号支持超过两级的列表[/-] [+]Preview mode copy to WeChat MP supports lists with more than two levels[/+] on Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @88250@Vanessa219@Achuan-2@TCOTC

      Issue actions

        Preview mode copy to WeChat MP supports lists with more than two levels · Issue #11276 · siyuan-note/siyuan