Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

编辑器解析 markdown 时候,normalize_mention_filter.rb 有问题 #1264

Open
clwy-cn opened this issue Feb 25, 2021 · 5 comments
Open

Comments

@clwy-cn
Copy link

clwy-cn commented Feb 25, 2021

例如有以下代码:

保存后变成了

@user1rocessor
def view_share():
    return dict(_admin='am-active')

感觉正则是不是有问题?或者说在代码段中,是否不应该实现mention功能

@Dounx
Copy link
Contributor

Dounx commented Apr 1, 2021

@admin_blue.context_processor
def view_share():
    return dict(_admin='am-active')

@Dounx
Copy link
Contributor

Dounx commented Apr 1, 2021

原因在这里:

next unless content.include?("@")

py 的代码(非预期):

@admin_blue.context_processor

处理的时候会生成:

<div class="highlight"><pre class="highlight python"><code><span class="o">@</span><span class="n">user1rocessor</span>
</code></pre></div>

user1rocessor 导致在遍历的时候无法还原回去。

而 rb 的代码(预期):

@admin_blue.context_processor

处理的时候会生成:

<div class="highlight"><pre class="highlight ruby"><code><span class="vi">@user1rocessor</span>
</code></pre></div>

@user1rocessor 在遍历的时候就能正确还原。

@qichunren
Copy link
Member

qichunren commented Feb 17, 2022

@Dounx 原因的确如你所说,你有解决办法吗?

我感觉解决办法应该是改进 normalize_mention_filter.rb ,不能直接简单全文的搜集 @xxxx, 应该在除了code块外面搜集,这一块的正则有些复杂啊。

@Dounx
Copy link
Contributor

Dounx commented Feb 18, 2022

有临时的解决办法,但是感觉不能从根本上解决问题(

可能要思考下怎么样改进 @ 方法。

@neozhaoliang
Copy link

neozhaoliang commented Jun 22, 2022

可不可以改成调用 pandoc 的 filter ,而不是自己手写?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants