Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

Move processing code into processor factory (shrink main window code)

AuthorDaveJarvis <email>
Date2020-09-21 21:04:07 GMT-0700
Commit69c8a049c4563c6338dff8ba6b4cca16f34e82a6
Parentb2687f1
Delta16 lines added, 0 lines removed, 16-line increase
src/main/java/com/keenwrite/processors/ProcessorFactory.java
*/
+ /**
+ * Executes the processing chain, operating on the given string.
+ *
+ * @param handler The first processor in the chain to call.
+ * @param text The initial value of the text to process.
+ * @return The final value of the text that was processed by the chain.
+ */
+ public static String processChain( Processor<String> handler, String text ) {
+ while( handler != null && text != null ) {
+ text = handler.apply( text );
+ handler = handler.next();
+ }
+
+ return text;
+ }
+
private Processor<String> createHTMLPreviewProcessor() {
return new HtmlPreviewProcessor( getPreviewPane() );