本文整理汇总了Java中com.vladsch.flexmark.Extension类的典型用法代码示例。如果您正苦于以下问题:Java Extension类的具体用法?Java Extension怎么用?Java Extension使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Extension类属于com.vladsch.flexmark包,在下文中一共展示了Extension类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MarkdownCompiler
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
@Inject
public MarkdownCompiler(Set<Extension> extensionSet, Set<MutableDataSet> injectedOptions) {
super(900);
MutableDataSet options = new MutableDataSet();
options.set(HtmlRenderer.GENERATE_HEADER_ID, true);
options.set(HtmlRenderer.RENDER_HEADER_ID, true);
options.set(Parser.EXTENSIONS, extensionSet);
for(MutableDataSet injectedOption : injectedOptions) {
options.setAll(injectedOption);
}
parser = Parser.builder(options).build();
renderer = HtmlRenderer.builder(options).build();
}
示例2: addExtension
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public void addExtension(Extension extension) {
List<Extension> extensions = getExtensions();
if(!containsExtension(extension)) {
Collections.addAll(extensions, extension);
setExtensions(extensions);
}
}
示例3: addExtension
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
protected void addExtension(final MarkdownParser markdownParser, Extension extension) {
List<Extension> extensions = markdownParser.getExtensions();
if(isSelected() && !extensions.contains(extension)) {
extensions.add(extension);
}else if(extensions.contains(extension)) {
extensions.remove(extension);
}
markdownParser.setExtensions(extensions);
}
示例4: configure
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
@Override
protected void configure() {
super.configure();
bind(WicketServlet.class).to(DefaultWicketServlet.class);
bind(WicketFilter.class).to(DefaultWicketFilter.class);
bind(WebSocketPolicy.class).toInstance(WebSocketPolicy.newServerPolicy());
bind(EditSupportRegistry.class).to(DefaultEditSupportRegistry.class);
bind(WebSocketManager.class).to(DefaultWebSocketManager.class);
contribute(CommitMessageTransformer.class, PatternCommitMessageTransformer.class);
contributeFromPackage(EditSupport.class, EditSupport.class);
bind(WebApplication.class).to(GitPlexWebApplication.class);
bind(Application.class).to(GitPlexWebApplication.class);
bind(AvatarManager.class).to(DefaultAvatarManager.class);
bind(WebSocketManager.class).to(DefaultWebSocketManager.class);
contributeFromPackage(EditSupport.class, EditSupportLocator.class);
bind(CommitIndexedBroadcaster.class);
contributeFromPackage(DiffRenderer.class, DiffRenderer.class);
contributeFromPackage(BlobRendererContribution.class, BlobRendererContribution.class);
contribute(Extension.class, new EmojiExtension());
contribute(Extension.class, new SourcePositionTrackExtension());
contribute(HtmlTransformer.class, new MentionTransformer());
contribute(HtmlTransformer.class, new PullRequestTransformer());
contribute(ResourcePackScopeContribution.class, new ResourcePackScopeContribution() {
@Override
public Collection<Class<?>> getResourcePackScopes() {
return Lists.newArrayList(WebModule.class);
}
});
contribute(ExpectedExceptionContribution.class, new ExpectedExceptionContribution() {
@SuppressWarnings("unchecked")
@Override
public Collection<Class<? extends Exception>> getExpectedExceptionClasses() {
return Sets.newHashSet(ConstraintViolationException.class, EntityNotFoundException.class,
ObjectNotFoundException.class, StaleStateException.class, UnauthorizedException.class,
GitException.class, PageExpiredException.class, StalePageException.class);
}
});
bind(UrlManager.class).to(DefaultUrlManager.class);
bind(CodeCommentChangeBroadcaster.class);
bind(PullRequestChangeBroadcaster.class);
bind(TaskChangeBroadcaster.class);
}
示例5: DefaultMarkdownManager
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
@Inject
public DefaultMarkdownManager(Set<Extension> contributedExtensions, Set<HtmlTransformer> htmlTransformers) {
this.contributedExtensions = contributedExtensions;
this.htmlTransformers = htmlTransformers;
whiteList = new Whitelist() {
@Override
protected boolean isSafeAttribute(String tagName, Element el, Attribute attr) {
if (attr.getKey().startsWith("data-"))
return true;
else
return super.isSafeAttribute(tagName, el, attr);
}
};
whiteList.addTags(SAFE_TAGS)
.addAttributes("a", "href", "title")
.addAttributes("img", "align", "alt", "height", "src", "title", "width")
.addAttributes("div", "itemscope", "itemtype")
.addAttributes(":all", SAFE_ATTRIBUTES)
.addProtocols("a", "href", SAFE_ANCHOR_SCHEMES)
.addProtocols("blockquote", "cite", "http", "https")
.addProtocols("cite", "cite", "http", "https")
.addProtocols("img", "src", "http", "https")
.addProtocols("q", "cite", "http", "https")
.preserveRelativeLinks(true);
}
示例6: render
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
@Override
public String render(String markdown, @Nullable String baseUrl, boolean postProcess) {
Preconditions.checkArgument(baseUrl == null || baseUrl.startsWith("/"));
List<Extension> extensions = new ArrayList<>();
extensions.add(AnchorLinkExtension.create());
extensions.add(TablesExtension.create());
extensions.add(TaskListExtension.create());
extensions.add(DefinitionExtension.create());
extensions.add(TocExtension.create());
extensions.add(AutolinkExtension.create());
extensions.add(new UrlResolveExtension());
extensions.addAll(contributedExtensions);
MutableDataHolder options = new MutableDataSet()
.set(HtmlRenderer.GENERATE_HEADER_ID, true)
.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true)
.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "header-anchor")
.set(AnchorLinkExtension.ANCHORLINKS_TEXT_SUFFIX, "<i class='fa fa-link'></i>")
.set(Parser.SPACE_IN_LINK_URLS, true)
.setFrom(ParserEmulationProfile.GITHUB_DOC)
.set(TablesExtension.COLUMN_SPANS, false)
.set(TablesExtension.APPEND_MISSING_COLUMNS, true)
.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true)
.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true)
.set(UrlResolveExtension.BASE_URL, baseUrl)
.set(Parser.EXTENSIONS, extensions);
Parser parser = Parser.builder(options).build();
HtmlRenderer htmlRenderer = HtmlRenderer.builder(options).build();
Node document = parser.parse(markdown);
String html = htmlRenderer.render(document);
if (postProcess)
html = postProcess(html);
return html;
}
示例7: configure
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
@Override
protected void configure() {
addToSet(Extension.class,
AsideExtension.create(),
AttributesExtension.create(),
EnumeratedReferenceExtension.create(),
StrikethroughSubscriptExtension.create(),
TablesExtension.create(),
TaskListExtension.create(),
TocExtension.create()
);
}
示例8: MarkdownAssetsServlet
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
/**
* Construct a {@link MarkdownAssetsServlet} configured with provided parameters, having a wrapped default
* {@link AssetServlet} for fulfilling non-markdown asset requests.
* <p>
* {@code MarkdownAssetsServlet} and {@link AssetServlet} serve static assets loaded from {@code resourceURL}
* (typically a file: or jar: URL). The assets are served at URIs rooted at {@code uriPath}. For
* example, given a {@code resourceURL} of {@code "file:/data/assets"} and a {@code uriPath} of
* {@code "/js"}, an {@code AssetServlet} would serve the contents of {@code
* /data/assets/example.js} in response to a request for {@code /js/example.js}. If a directory
* is requested and {@code indexFile} is defined, then {@code AssetServlet} will attempt to
* serve a file with that name in that directory.
* @param resourcePath the base URL from which assets are loaded
* @param uriPath the URI path fragment in which all requests are rooted
* @param indexFile the filename to use when directories are requested
* @param defaultCharset the default character set
* @param configuration environment-specific configuration properties
* @param extensions Flexmark-Java markdown rendering extensions to use
* @param options Flexmark-Java markdown rendering options
* @param cacheBuilderSpec {@link CacheBuilderSpec} for rendered pages
*/
public MarkdownAssetsServlet(@NotNull String resourcePath,
@NotNull String uriPath,
@NotNull String indexFile,
@NotNull Charset defaultCharset,
@NotNull MarkdownAssetsConfiguration configuration,
@NotNull List<Extension> extensions,
@NotNull DataHolder options,
@NotNull CacheBuilderSpec cacheBuilderSpec) {
this.resourcePath = resourcePath;
this.uriPath = uriPath;
this.indexFile = indexFile;
this.defaultCharset = defaultCharset;
this.configuration = configuration;
parser = Parser.builder(options).extensions(extensions).build();
renderer = HtmlRenderer.builder(options).extensions(extensions).build();
assetServlet = new AssetServlet(resourcePath, uriPath, indexFile, defaultCharset);
pageCache = CacheBuilder.from(cacheBuilderSpec)
.build(new CacheLoader<URL, CachedPage>() {
@Override
public CachedPage load(@NotNull URL key) throws Exception {
return renderPage(key);
}
});
try {
URL resource = this.getClass().getResource(resourcePath);
Preconditions.checkNotNull(resource, "Resource root URL (" + resourcePath + ") was not found");
resourceRootURL = resource.toURI();
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Resource root URL (" + resourcePath + ") was ind", e);
}
}
示例9: setExtensions
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public void setExtensions(List<Extension> extensions) {
options.remove(EXTENSIONS);
options.set(EXTENSIONS, extensions);
logger.debug("Resetting markdown parser extensions: {}", options.get(Parser.EXTENSIONS).toString());
}
示例10: getExtensions
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public List<Extension> getExtensions() {
return (List<Extension>) options.get(Parser.EXTENSIONS);
}
示例11: containsExtension
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
private boolean containsExtension(final Extension extension) {
final AtomicBoolean flag = new AtomicBoolean(false);
getExtensions().forEach(ext -> {
if(ext.getClass().getName().equals(extension.getClass().getName())){
flag.set(true);
}
});
return flag.get();
}
示例12: create
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public static Extension create() {
return new LocalizationExtension();
}
示例13: create
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public static Extension create() {
return new TwitterExtension();
}
示例14: create
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public static Extension create() {
return new KeystrokeExtension();
}
示例15: create
import com.vladsch.flexmark.Extension; //导入依赖的package包/类
public static Extension create() {
return new MarkExtension();
}