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

Code blocks support for all formats. Single line break support #123

Merged
merged 3 commits into from
Dec 11, 2019

Conversation

hmalphettes
Copy link
Contributor

@hmalphettes hmalphettes commented Sep 21, 2019

Prerequisites

  • This pull request fixes a bug.
  • This pull request adds a feature.
  • This pull request enhances existing functionality.
  • This pull request introduces breaking change.

For more information, see the Contributing Guide.

Description

Add support for embedding markdown code blocks in the heredoc of a variable description.

For the markdown table format, the code blocks are formatted as HTML on a single line.
For the markdown document format, the code blocks are kept untouched.

Support for single-line breaks: when the line ends with 2 spaces, place
a single <br> for the markdown table format.
For the other format, make sure to not trim the line and keep the newline in place.

This pull request supports rendering

variable "input-with-code-block" {
  description = <<EOD
This is a complicated one. We need a newline.  
And an example in a code block
\```
default     = [
  "machine rack01:neptune"
]
\```
EOD
  default     = [
    "name rack:location"
  ]
}

Into

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| input-with-code-block | This is a complicated one. We need a newline.<br>And an example in a code block<code><pre>default     = [<br>  "machine rack01:neptune"<br>]<br></pre></code> | list | `<list>` | no |

Screenshot 2019-09-21 at 3 47 42 PM

Issues Resolved

No issues were previously filed.

Checklist

Put an x into all boxes that apply:

Tests

  • I have added tests to cover my changes.
  • All tests pass when I run make test.

I have done rushed job at keeping the tests suite green after adding a variable to the examples folder. That final pass of sanitization for the document format has a single merit: "it works".
I would not merge it though.

Please let me know if there is sufficient interest for this new feature and I'll put in some effort in refactoring the code.

Documentation

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Code Style

  • My code follows the code style of this project.

@hmalphettes hmalphettes force-pushed the md-code-block-in-tables branch 3 times, most recently from 6f908ad to ac722ff Compare September 21, 2019 14:24
@hmalphettes hmalphettes changed the title HTML-ize code blocks inside a markdown table. Single line break HTML-ize code blocks inside tables and outside. Single line break Sep 21, 2019
@hmalphettes hmalphettes changed the title HTML-ize code blocks inside tables and outside. Single line break Code blocks support for all formats. Single line break support Sep 22, 2019
 Add support for embedding markdown code blocks inside markdown tables

 Add support for single-line breaks: when the line ends with 2 spaces, place
 a single <br>.
@khos2ow
Copy link
Member

khos2ow commented Sep 25, 2019

Thanks @hmalphettes for your PR. I'll review it soon.

@khos2ow
Copy link
Member

khos2ow commented Dec 11, 2019

Thank you @hmalphettes , sorry for the long delay!

@khos2ow khos2ow merged commit ab42f0d into terraform-docs:master Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants