All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.tomakeitgo.markdown.se.MarkdownConverter Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
package com.tomakeitgo.markdown.se;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * A MarkdownConverter is used to convert markdown into its resulting expressions.
 * 

* There are four predefined functions. *

    *
  • ___define___ ( (parameters), body ) -> Empty. allows new functions to be defined
  • *
  • ___no_spaces___ ( exp ) -> Symbol. Reduces the expression taken combining the results with no delimiter
  • *
  • ___default___ ( exp ) -> Symbol. Reduces the expression taken combining the results with a space delimiter
  • *
  • ___paren___ ( exp ) -> Symbol. Reduces the expression taken combining the results with a space delimiter, prefix (, and suffix )
  • *
*/ public class MarkdownConverter { private final Evaluator evaluator = new Evaluator(); /** * The method convert will read the inputStream, evaluate the markdown, and write the results to the output stream. * The inputStream and outputStream will not be closed. *

* Calls to convert will modify the state of the converter. Functions defined in the global scope will carry over between runs. * * @param inputStream The source that is to be read and evaluated * @param outputStream The destination for the results of the conversion * @throws IOException will be thrown if an error occurs reading or writing. */ public void convert(InputStream inputStream, OutputStream outputStream) throws IOException { outputStream.write(evaluator.eval(new Parser(new Lexer(inputStream)).parse()).getValue().getBytes()); outputStream.flush(); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy