homeland
homeland copied to clipboard
编辑器解析 markdown 时候,normalize_mention_filter.rb 有问题
例如有以下代码:
保存后变成了
@user1rocessor
def view_share():
return dict(_admin='am-active')
感觉正则是不是有问题?或者说在代码段中,是否不应该实现mention功能
@admin_blue.context_processor
def view_share():
return dict(_admin='am-active')
原因在这里:
https://github.com/ruby-china/homeland/blob/0285a3fc50643c69b0bee72fb4f74567487836da/lib/homeland/pipeline/mention_filter.rb#L19
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 在遍历的时候就能正确还原。
@Dounx 原因的确如你所说,你有解决办法吗?
我感觉解决办法应该是改进 normalize_mention_filter.rb ,不能直接简单全文的搜集 @xxxx, 应该在除了code块外面搜集,这一块的正则有些复杂啊。
有临时的解决办法,但是感觉不能从根本上解决问题(
可能要思考下怎么样改进 @ 方法。
可不可以改成调用 pandoc 的 filter ,而不是自己手写?