繁体   English   中英

逆向工程字符串格式化过程

[英]Reverse engineer string formarting process

我正在为我的所见即所得数据输入组件使用 slate-react 编辑器,该组件将显示在 Telegram 上。

然后按照 Telegram 的要求对文本输入进行格式化,如本例所示:

Slate Object
[
    {
        "type": "paragraph",
        "children": [
            {
                "text": "Dry grains to moisture content of below 12 percent and dress with crop "
            },
            {
                "text": "protection ",
                "bold": true
            },
            {
                "text": "products such as Actellic 2%. Seeds meant for planting should not be stored for more than six "
            },
            {
                "text": "months",
                "underline": true
            },
            {
                "text": ". For more "
            },
            {
                "text": "information",
                "underline": true
            },
            {
                "text": ", please contact your "
            },
            {
                "text": "local ",
                "italic": true
            },
            {
                "text": "Extension Agent."
            }
        ]
    }
]

然后我将字符串格式化为 Telegram 规范,如下所示:

Dry grains to moisture content of below 12 percent and dress with crop **protection **products such as Actellic 2%. Seeds meant for planting should not be stored for more than six months. For more information, please contact your _local _Extension Agent.

我现在想对该过程进行逆向工程,以便如果给定这样的字符串,我可以生成上面的 object,以便我能够在编辑器上显示它。 我想帮助制定能够达到预期结果的 function。

对于将来可能需要此类信息的人,感谢@Phil,我从评论中获得了指针,我能够在网上搜索 markdown 标记器。 Prismjs 就像一个魅力。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM