Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render as plain text #34

Open
nh13 opened this issue Jun 24, 2016 · 1 comment
Open

Render as plain text #34

nh13 opened this issue Jun 24, 2016 · 1 comment
Milestone

Comments

@nh13
Copy link

nh13 commented Jun 24, 2016

@jenshalm, I was wondering if there was any appetite for accepting a patch for a plain-text renderer:
```class PlainText extends RendererFactory[TextWriter]`?

The use case I have for such a renderer is to be able to use markup in the description and usage messages for options in an option parser (command line parser) library. The plain-text rendered output would go to the terminal, so I am also considering optionally having ANSI terminal codes to be used for some of the elements. Since the various option help and usage messages are in Markup, we can then also render the command line usage messages in HTML for displaying on a documentation site, or in PDF for distribution elsewhere.

I was thinking of starting from the render.HTML class and the associated test class and adapt it until it produces plain-text.

What do folks think of this idea?

@jenshalm
Copy link
Contributor

Sorry for the late response, I somehow overlooked this issue. I think rendering terminal text is maybe a bit of an edge case, but if it is a feature-complete implementation with a full test case I would accept it.

In case you are still planning on doing this, here are a few suggestions:

  • If it includes terminal codes, maybe a name like TerminalText for the renderer would be a better fit than just PlainText?
  • You might also need to create a custom writer TerminalTextWriter as a subclass of TextWriter. The reason is that Laika is extensible and users can override the rendering per node type. The renderer you provide just contains the defaults. This means that if you hide all convenient helpers in the renderer, they are not available for the user, as it is the Writer API that they use for overriding rendering for a node. See http://planet42.github.io/Laika/customizing-laika/customize-rendering.html for examples.

@jenshalm jenshalm added this to the Backlog milestone Aug 30, 2016
@jenshalm jenshalm changed the title Appetite for a plain-text renderer Render as plain text Nov 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants