# 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:** 13

<div class="post-metadata">

**Author:** ![jgm](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/jgm/32/1360_2.png) [@jgm](https://talk.commonmark.org/u/jgm)\
**Post date:** [January 29, 2016, 7:03pm UTC](https://talk.commonmark.org/t/customizable-renderer-output-in-commonmark-js/1146/13 "2016-01-29T19:03:53Z")

</div>

@tmpfs see the thread

> [@Should there be additional information in the AST?](https://talk.commonmark.org/t/should-there-be-additional-information-in-the-ast/2138):
>
> Continuing the discussion from [Issues we SHOULD resolve before 1.0 release](https://talk.commonmark.org/t/issues-we-should-resolve-before-1-0-release/2136): Currently we lose information about: whether a link was an autolink whether it was a reference link, what kind, and what label what the bullet character was for a list item what character was used for emphasis/strong emphasis whether the 1. or 1) style of ordered list was used. whether a code block was backtick or indented Should some or all of these things be part of the AST, or is this too “concrete”? (This would m…

Of course, even if the spec doesn’t say that this information needs to be preserved (and in my view it probably shouldn’t), our implementations could preserve it.

It would be quite easy to modify commonmark.js to keep track of what character was used for emphasis, how many backticks were used in a backtick code block, what type of hard line break was used, and whether a fenced or indented code block was used (in cases where the info string is empty).

Keeping track of whether a link or image was inline or reference (and label was used for the reference) would also be relatively easy. The tricky part would be knowing where the reference goes, since this isn’t tracked in the AST. Putting them all at the end would be easy, though.

About your use case: you don’t need a CommonMark renderer for that, unless the source code blocks sometimes occur in indented contexts (blockquotes or lists). All you’d need is a preprocessor or template engine to insert the contents of the source files into specially marked code blocks.

---

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