vsch / flexmark-java

CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
BSD 2-Clause "Simplified" License
2.26k stars 269 forks source link

Request for information: configuration to format a markdown document on a console #555

Closed jlerbsc closed 1 year ago

jlerbsc commented 1 year ago

How can flexmark be configured to format a markdown document on a console?

I am using the spring shell library on a client application which must display help on the console which is formatted in markdown. I would like this help to be displayed in a formatted text form. How can I do this? Is there an extension I could use to get this rendering.

ghost commented 1 year ago

This isn't a responsibility of flexmark-java. It's up to the developer who wants to use the library to make a program tailored to their particular requirements.

My text editor, KeenWrite, uses flexmark-java both when running from the command-line and from running through the user interface.

Broadly:

  1. Write a Java program that has a main(String args[]).
  2. Open a file from the given arguments, or open standard input.
  3. Read from the stream.
  4. Create a newly configured instance of flexmark-java's parser.
  5. Pass the stream (or its contents) to the parser.
  6. Write the transformed document to standard output (or a file if given on the command-line).
  7. Close the streams (do not cross the streams).

How you implement this is your responsibility, flexmark-java will only do the heavy lifting of transforming the document.

ghost commented 1 year ago

@jlerbsc if this answers your question, please close the ticket. You may wish to ask specific questions about integration on StackOverflow.

Otherwise, please add more details about your question.