-
Notifications
You must be signed in to change notification settings - Fork 134
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
Add line wrapping / breaking to emitter #200
Comments
👍 Yes, we should definitely implement this! Doing so would enable a tool like API Extractor to normalize the comment format when it writes a .d.ts file for release. Another idea would be to emit the |
When I started working on this, I realized that the emitter should probably support three separate modes:
@iansan5653 I'm wondering, would verbatim be more appropriate for your application than trim spaces and word wrap? |
Also note that word-wrap probably cannot be applied to other sections such as |
I don't think so, unless I misunderstand what you're asking - I'd like to make a tool that, no matter how the input content is formatted, always produces the same standardized output. Lines wrapped, tags in the same order, newlines where they should be and not where they shouldn't, etc. |
👍 Got it. I'll see if I can implement this. I started work on it over the weekend, but ran into some deeper architectural questions that I need to think about before I write too much code. |
I don't think this comment is entirely accurate:
Markdown doesn't "misinterpret" extra spaces/newlines. Rather, Markdown is a whitespace-significant language and has very specific behavior with regards to the number of whitespaces and newlines that it encounters. Here are a few common examples:
In my opinion, the best thing to do is to parse out the TSDoc specific syntax ( You can find the latest specification for commonmark (the Markdown spec that Github-Flavored Markdown is based on) here: https://spec.commonmark.org/0.29/ |
Note that whitespace is also significant inside a pullquote: > line 1
>
> code
>
> line 2
|
@rbuckton We started with this idea. However, it conflicts with two of TSDoc's overarching goals:
I originally thought that CommonMark would address these concerns. But it doesn't. CommonMark has many gotchas where an expression gets parsed unexpectedly. And as a unifying "standard", CommonMark turned out to be a standard that nobody actually implements: Every single Markdown engine adds its own proprietary grammar extensions that, when used, can cause an entire input to be misinterpreted by other engines. As evidence, consider this code: | Col1 | Col2 |
| --- | --- |
| `{@link X | Y}` |
| {@link X | Y} | How it gets parsed:
(There are endless examples like this. If you put TSDoc's concern: Is there a
|
Currently, the emitter seems to have no option or support for breaking lines at a certain length. If a parameter description has a 500-character block of text, all of that text will be on the same line. It would be really useful to have some sort of parameter or setting to automatically wrap text when a certain number of characters is reached in a line.
The text was updated successfully, but these errors were encountered: