解析,添加下标/上标 [英] Parsedown, add sub/superscript

查看:124
本文介绍了解析,添加下标/上标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将子目录/上标添加到 Parsedown .

I am trying to add sub/superscript to Parsedown.

Parsedown 的功能在我看来像是一个丛林.我一直在试图理解它,但无法对其进行解密.

Parsedown's functions seem like a jungle to me. I've been trying to understand it but have been unable to decipher it.

将〜text〜转换为<sub>text</sub>似乎比我想象的要困难得多.

Turning ~text~ into <sub>text</sub> seems to be more of a challenge than I'd thought.

我全神贯注于他的代码结构,这是我做不到的,任何帮助将不胜感激.

Wrapping my head around the structure of his code, is just something that I can't and any help would be extremely appreciated.

推荐答案

这是一个非常简单的正则表达式.

This is a very simple regex.

使用:

\~(.*)\~|\^\((.*)\)

替换为< sub> \ 1 \ 2</sub>

With the substitution <sub>\1\2</sub>

正则表达式中有两个组.这里的关键是组不会同时匹配,这就是为什么您可以使用\ 1 \ 2

There are two groups in the regex. The key thing here is that the groups won't match at the same time, this is why you can use \1\2

演示

尝试理解它,并在需要更复杂的东西时加以改进.

Try to understand it and improve if you need something more sophisticated.

这篇关于解析,添加下标/上标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆