| Author | DaveJarvis <email> |
|---|---|
| Date | 2023-11-25 21:31:26 GMT-0800 |
| Commit | c6f609b6854782ab37f5a1385684949bd39752d2 |
| Parent | 37ea775 |
| Delta | 58 lines added, 48 lines removed, 10-line increase |
| import com.keenwrite.ExportFormat; | ||
| import com.keenwrite.processors.ProcessorContext; | ||
| -import com.keenwrite.processors.markdown.extensions.common.MarkdownExtension; | ||
| +import com.keenwrite.processors.markdown.extensions.common.MarkdownRendererExtension; | ||
| import com.keenwrite.processors.markdown.extensions.tex.TexNodeRenderer.TexNodeRendererFactory; | ||
| import com.vladsch.flexmark.html.renderer.NodeRendererFactory; | ||
| * performance. | ||
| */ | ||
| -public class TexExtension extends MarkdownExtension { | ||
| +public class TexExtension extends MarkdownRendererExtension { | ||
| /** | ||
| * Responsible for pre-parsing the input. | ||
| package com.keenwrite.processors.markdown.extensions.references; | ||
| -import com.keenwrite.processors.markdown.extensions.common.MarkdownExtension; | ||
| +import com.keenwrite.processors.markdown.extensions.common.MarkdownRendererExtension; | ||
| import com.vladsch.flexmark.html.renderer.NodeRendererFactory; | ||
| import com.vladsch.flexmark.parser.Parser.Builder; | ||
| /** | ||
| * Responsible for processing {@code {@type:id}} anchors and their corresponding | ||
| * {@code [@type:id]} cross-references. | ||
| */ | ||
| -public final class CrossReferenceExtension extends MarkdownExtension { | ||
| +public final class CrossReferenceExtension extends MarkdownRendererExtension { | ||
| /** | ||
| * Use {@link #create()}. |
| -/* Copyright 2023 White Magic Software, Ltd. -- All rights reserved. | ||
| - * | ||
| - * SPDX-License-Identifier: MIT | ||
| - */ | ||
| -package com.keenwrite.processors.markdown.extensions.common; | ||
| - | ||
| -import com.keenwrite.processors.markdown.extensions.HtmlRendererAdapter; | ||
| -import com.vladsch.flexmark.html.HtmlRenderer.Builder; | ||
| -import com.vladsch.flexmark.html.renderer.NodeRenderer; | ||
| -import com.vladsch.flexmark.html.renderer.NodeRendererFactory; | ||
| -import com.vladsch.flexmark.parser.Parser.ParserExtension; | ||
| -import com.vladsch.flexmark.util.data.MutableDataHolder; | ||
| -import org.jetbrains.annotations.NotNull; | ||
| - | ||
| -public abstract class MarkdownExtension extends HtmlRendererAdapter | ||
| - implements ParserExtension { | ||
| - | ||
| - /** | ||
| - * Implemented by subclasses to create the {@link NodeRendererFactory} capable | ||
| - * of converting nodes created by an extension into HTML elements. | ||
| - * | ||
| - * @return The {@link NodeRendererFactory} for producing {@link NodeRenderer} | ||
| - * instances. | ||
| - */ | ||
| - protected abstract NodeRendererFactory createNodeRendererFactory(); | ||
| - | ||
| - /** | ||
| - * Adds an extension for HTML document export types. | ||
| - * | ||
| - * @param builder The document builder. | ||
| - * @param rendererType Indicates the document type to be built. | ||
| - */ | ||
| - @Override | ||
| - public void extend( | ||
| - @NotNull final Builder builder, | ||
| - @NotNull final String rendererType ) { | ||
| - if( "HTML".equalsIgnoreCase( rendererType ) ) { | ||
| - builder.nodeRendererFactory( createNodeRendererFactory() ); | ||
| - } | ||
| - } | ||
| - | ||
| - @Override | ||
| - public void parserOptions( final MutableDataHolder options ) {} | ||
| -} | ||
| +/* Copyright 2023 White Magic Software, Ltd. -- All rights reserved. | ||
| + * | ||
| + * SPDX-License-Identifier: MIT | ||
| + */ | ||
| +package com.keenwrite.processors.markdown.extensions.common; | ||
| + | ||
| +import com.vladsch.flexmark.parser.Parser.ParserExtension; | ||
| +import com.vladsch.flexmark.util.data.MutableDataHolder; | ||
| + | ||
| +/** | ||
| + * Provides a default {@link #parserOptions(MutableDataHolder)} implementation. | ||
| + */ | ||
| +public interface MarkdownParserExtension extends ParserExtension { | ||
| + @Override | ||
| + default void parserOptions( final MutableDataHolder options ) {} | ||
| +} | ||
| +/* Copyright 2023 White Magic Software, Ltd. -- All rights reserved. | ||
| + * | ||
| + * SPDX-License-Identifier: MIT | ||
| + */ | ||
| +package com.keenwrite.processors.markdown.extensions.common; | ||
| + | ||
| +import com.vladsch.flexmark.html.HtmlRenderer.Builder; | ||
| +import com.vladsch.flexmark.html.renderer.NodeRenderer; | ||
| +import com.vladsch.flexmark.html.renderer.NodeRendererFactory; | ||
| +import org.jetbrains.annotations.NotNull; | ||
| + | ||
| +public abstract class MarkdownRendererExtension extends HtmlRendererAdapter | ||
| + implements MarkdownParserExtension { | ||
| + | ||
| + /** | ||
| + * Implemented by subclasses to create the {@link NodeRendererFactory} capable | ||
| + * of converting nodes created by an extension into HTML elements. | ||
| + * | ||
| + * @return The {@link NodeRendererFactory} for producing {@link NodeRenderer} | ||
| + * instances. | ||
| + */ | ||
| + protected abstract NodeRendererFactory createNodeRendererFactory(); | ||
| + | ||
| + /** | ||
| + * Adds an extension for HTML document export types. | ||
| + * | ||
| + * @param builder The document builder. | ||
| + * @param rendererType Indicates the document type to be built. | ||
| + */ | ||
| + @Override | ||
| + public void extend( | ||
| + @NotNull final Builder builder, | ||
| + @NotNull final String rendererType ) { | ||
| + if( "HTML".equalsIgnoreCase( rendererType ) ) { | ||
| + builder.nodeRendererFactory( createNodeRendererFactory() ); | ||
| + } | ||
| + } | ||
| +} | ||