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

mdformat mkdocs #37

Open
drakeredwind01 opened this issue Aug 15, 2024 · 3 comments
Open

mdformat mkdocs #37

drakeredwind01 opened this issue Aug 15, 2024 · 3 comments
Assignees

Comments

@drakeredwind01
Copy link

messed up lines:

  • 112 extra spaces
  • 121 - 129 extra spaces
  • 174 - [ ] **
  • others

zz Pre-work Checklist DevOps-Security-Member drakeredwind01 #36 1.md
zz Pre-work Checklist DevOps-Security-Member drakeredwind01 #36 2.md

@KyleKing KyleKing self-assigned this Aug 20, 2024
@KyleKing
Copy link
Owner

KyleKing commented Aug 22, 2024

Thanks for submitting an issue and trying out mdformat-mkdocs!

Update: most of the below explanation was incorrect. I didn't have enough context to understand the ticket and the intended markdown structure. See #39


There are a couple of issue with the source file that need to be manually resolved before mdformat will know how to parse. For the below examples, I generated the HTML with the online CommonMark app: https://spec.commonmark.org/dingus

Markdown treats indents as part of the language (https://spec.commonmark.org/0.31.2/#indented-code-blocks). For example:

<!-- 2.md Lines 102:107 -->
- [x] Install Terraform Docs locally by following the instructions of the installation guide mentioned in [Installing Terraform docs](https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#installing-terraform-docs)

    #### WINDOWS

    - if you have windows you first need [scoop](https://scoop.sh/#/)
    - run scoop command

Renders to HTML as a nested list in this case:

<ul>
  <li>
    <p>[x] Install Terraform Docs locally by following the instructions of the installation guide mentioned in <a href="https://github.com/hackforla/devops-security/blob/main/CONTRIBUTING.md#installing-terraform-docs">Installing Terraform docs</a>
    </p>
    <h4>WINDOWS</h4>
    <ul>
      <li>if you have windows you first need <a href="https://scoop.sh/#/">scoop</a>
      </li>
      <li>run scoop command</li>
    </ul>
  </li>
</ul>

Or if line 102 had been a paragraph instead of a list, then the indented text would be rendered as a code block:

<p>Text</p>
<pre>
	<code>#### WINDOWS

- if you have windows you first need [scoop](https://scoop.sh/#/)
- run scoop command
</code>
</pre>

Code within lists needs to be on its own line and in a fenced block (e.g. ```):

<!-- 2.md Lines 107:110 (unindented and code blocks moved to new lines) -->

  • run scoop command

    ```cmd
    scoop bucket add terraform-docs https://github.com/terraform-docs/scoop-bucket
    scoop install terraform-docs
    ```

    • if you don't have scoop run install it by running the following in powershell

      ```powershell
      iex (new-object net.webclient).DownloadString('https://get.scoop.sh')
      ```

      • if you get following error in red letters run the bellow command PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass] to run Scoop. For example, to set the execution policy to 'RemoteSigned' please run 'Set-ExecutionPolicy RemoteSigned -Scope CurrentUser'.

Renders to:

<!-- 2.md Lines 107:110 (unindented and code blocks moved to new lines) -->
<ul>
  <li>
    <p>run scoop command</p>
    <pre>
			<code class="language-cmd">scoop bucket add terraform-docs https://github.com/terraform-docs/scoop-bucket
scoop install terraform-docs
</code>
		</pre>
    <ul>
      <li>
        <p>if you don't have scoop run install it by running the following in powershell</p>
        <pre>
					<code class="language-powershell">iex (new-object net.webclient).DownloadString('https://get.scoop.sh')
</code>
				</pre>
        <ul>
          <li>if you get following error in red letters run the bellow command <code>PowerShell requires an execution policy in [Unrestricted, RemoteSigned, ByPass] to run Scoop. For example, to set the execution policy to 'RemoteSigned' please run 'Set-ExecutionPolicy RemoteSigned -Scope CurrentUser'.</code>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

@KyleKing
Copy link
Owner

Oh, I think I might have misunderstood a few things:

  • I see now that 1.md is the original text
  • And that the nested header within the list on line 102 was intended

With that understaning, I've pushed a formatted version of 1.md that appears to pass mdformat logic for review here: https://github.com/KyleKing/mdformat-mkdocs/pull/39/files

You can see the changes I made in this diff: 8972907

@KyleKing
Copy link
Owner

Also, TIL that this is valid Markdown:

  • iex (new-object net.webclient).DownloadString('https://get.scoop.sh')

I've created a feature request to support it, but it might be a week or two before I have time again: #40

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

No branches or pull requests

2 participants