# Customizable renderer output in commonmark.js

**URL:** <https://talk.commonmark.org/t/customizable-renderer-output-in-commonmark-js/1146>\
**Category:** Application\
**Created:** [April 16, 2015, 4:20am UTC](https://talk.commonmark.org/t/customizable-renderer-output-in-commonmark-js/1146 "2015-04-16T04:20:16Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![tmpfs](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/tmpfs/32/892_2.png) [@tmpfs](https://talk.commonmark.org/u/tmpfs)\
**Post date:** [January 29, 2016, 8:26am UTC](https://talk.commonmark.org/t/customizable-renderer-output-in-commonmark-js/1146/12 "2016-01-29T08:26:26Z")

</div>

I am encountering the same problem trying to create a renderer that produces Commonmark(down). The use case is quite simple (but there are many), to produce a README document from multiple markdown documents occasionally including file contents or the output of executing programs. I use this to keep the examples in my README in sync with the state of the repository.

Whilst I can certainly create a Renderer that does all the basics, if I want to output the document as close as possible to the original (I imagine only changes to whitespace might occur) then the `Parser` would need to be modified. Some examples:

- Determining the type of hard line break used (backslash or double spaces)
- Rendering link references (`[link]: http://example.com`)
- Determining the type of character used for emph, strong etc.

I am sure there are more I haven’t run into but as far as I can tell the AST does not expose enough information for me to achieve a lot of these tasks.

My personal feeling is that a round-trip back to Markdown should be possible. I ran into the same issue with `marked` previously with my initial implementation (which works) and had to fork the source.

I would really like not to fork `commonmark.js` and contribute to a `Parser` and `Renderer` design that allows rendering back to Commonmark (as well as HTML, XML, PDF, TXT, MAN etc).

So I just wanted to see if @jgm thought this problem was worth solving and to continue this discussion on what I think is an important topic.

---

_[View the full topic](https://talk.commonmark.org/t/customizable-renderer-output-in-commonmark-js/1146)._
