最近将网站后台文章编辑器改为Markdown。
直接写Markdown感觉比使用富文本编辑器更好,主要是富文本编辑会多出非常多的标签,编辑不受控制。
使用Markdown转换HTML就比较令人满意了。
但是这里又有一个问题了,就是外链没有加上rel="nofollow",我们需要自己实现这个功能,代码如下:
package com.acgist.utils;
import com.vladsch.flexmark.ast.AutoLink;
import com.vladsch.flexmark.ast.Link;
import com.vladsch.flexmark.html.AttributeProvider;
import com.vladsch.flexmark.html.AttributeProviderFactory;
import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.html.IndependentAttributeProviderFactory;
import com.vladsch.flexmark.html.renderer.AttributablePart;
import com.vladsch.flexmark.html.renderer.LinkResolverContext;
import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.profiles.pegdown.Extensions;
import com.vladsch.flexmark.profiles.pegdown.PegdownOptionsAdapt