Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git
src/main/java/com/keenwrite/MainPane.java
mProcessors.computeIfAbsent(
- editor, _ -> createProcessors(
- createProcessorContext( path ),
- createHtmlPreviewProcessor()
- )
+ editor, _ -> {
+ final var context = createProcessorContext( path );
+ final var preview = createHtmlPreviewProcessor( context );
+
+ return createProcessors(
+ context,
+ preview
+ );
+ }
);
}
* @return The {@link Processor} for rendering an HTML document.
*/
- private Processor<String> createHtmlPreviewProcessor() {
- return new HtmlPreviewProcessor( getPreview() );
+ private Processor<String> createHtmlPreviewProcessor(
+ final ProcessorContext context
+ ) {
+ return new HtmlPreviewProcessor( context, getPreview() );
}
src/main/java/com/keenwrite/processors/html/HtmlPreviewProcessor.java
import com.keenwrite.preview.HtmlPreview;
import com.keenwrite.processors.ExecutorProcessor;
+import com.keenwrite.processors.ProcessorContext;
+import com.whitemagicsoftware.keenquotes.parser.Curler;
+
+import static com.keenwrite.processors.html.Configuration.createCurler;
+import static com.whitemagicsoftware.keenquotes.lex.FilterType.FILTER_XML;
+import static com.whitemagicsoftware.keenquotes.parser.Apostrophe.CONVERT_RSQUOTE;
/**
* Responsible for notifying the {@link HtmlPreview} when the succession
* chain has updated. This decouples knowledge of changes to the editor panel
* from the HTML preview panel as well as any processing that takes place
* before the final HTML preview is rendered. This is the last link in the
* processor chain.
*/
public final class HtmlPreviewProcessor extends ExecutorProcessor<String> {
+ private static final Curler CURLER = createCurler(
+ FILTER_XML, CONVERT_RSQUOTE
+ );
+
+ /**
+ * Allows quote curling in the preview panel.
+ */
+ private final ProcessorContext mContext;
+
/**
* There is only one preview panel.
*/
- private static HtmlPreview sHtmlPreview;
+ private static HtmlPreview sPreview;
/**
* Constructs the end of a processing chain.
*
- * @param htmlPreview The pane to update with the post-processed document.
+ * @param context Typesetting options.
+ * @param preview The pane to update with the post-processed document.
*/
- public HtmlPreviewProcessor( final HtmlPreview htmlPreview ) {
- sHtmlPreview = htmlPreview;
+ public HtmlPreviewProcessor(
+ final ProcessorContext context,
+ final HtmlPreview preview ) {
+ mContext = context;
+ sPreview = preview;
}
public String apply( final String html ) {
assert html != null;
+ final var result = mContext.getCurlQuotes() ? CURLER.apply( html ) : html;
- sHtmlPreview.render( html );
+ sPreview.render( result );
return html;
}
src/main/java/com/keenwrite/processors/markdown/MarkdownProcessor.java
*/
public final class MarkdownProcessor extends BaseMarkdownProcessor {
-
private MarkdownProcessor(
final Processor<String> successor, final ProcessorContext context ) {

Curls quotes in preview

Author DaveJarvis <email>
Date 2024-10-14 21:00:29 GMT-0700
Commit 7a93835d1cf2008ba138f135e38f60d8bd210efa
Parent 4b89e80
Delta 38 lines added, 12 lines removed, 26-line increase