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

Remove newlines inside & inbetween block-elements for better readability #12

Closed
EvitanRelta opened this issue Dec 11, 2022 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@EvitanRelta
Copy link
Owner

EvitanRelta commented Dec 11, 2022

Currently, the below HTML:

<blockquote forcehtml>
    <p>Line 1</p>
    <p>Line 2</p>
<pre><code>Codeblock
</code></pre>
    <h1>Heading</h1>
</blockquote>

is converted to:

<blockquote>
  <p>
    Line 1
  </p>
  
  <p>
    Line 2
  </p>
  
<pre><code>Codeblock
</code></pre>
  
  <h1>
    Heading
  </h1>
</blockquote>

which has alot of unnecessary newlines.


It would be nice to remove the newlines inbetween inner block-elements (eg. paragraphs/codeblocks/headings), as well as make each inner block-element take only 1 line, like so:

<blockquote>
  <p>Line 1</p>
  <p>Line 2</p>
<pre><code>Codeblock
</code></pre>
  <h1>Heading</h1>
</blockquote>

Note: The removal of newlines inbetween inner block-elements inside blockquotes can be achieved by passing down a boolean, which controls whether to add \n\n to end of the inner-content in each block-element-rule


Similarly, block-elements that has no attributes and contain 1 liner inner-content (ie. contains no \n), can be made into 1 liners to improve readability, like so:

<!-- Improved 1 liner -->
<p>TEXT</p>

<!-- Current multi-line block-elements -->
<p>
  TEXT
</p>
@EvitanRelta EvitanRelta added improve Improvements on existing feature bug Something isn't working labels Dec 11, 2022
@EvitanRelta
Copy link
Owner Author

When prototyping the table conversion, I discovered that this HTML:

<table forcehtml>
  <thead>
    <tr>
      <th>h1</th>
      <th>h2</th>
      <th>h3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>c1</td>
      <td>c1</td>
      <td>c3</td>
    </tr>
    </tr>
  </tbody>
</table>

which converted to this markdown:

<table>
  <tr>
    <th>
      h1
    </th>
    
    <th>
      h2
    </th>
    
    <th>
      h3
    </th>
  </tr>
  
  <tr>
    <td>
      c1
    </td>
    
    <td>
      c1
    </td>
    
    <td>
      c3
    </td>
  </tr>
</table>

incorrectly renders in GitHub as shown:

<th>
  h2
</th>

<th>
  h3
</th>
<td>
  c1
</td>

<td>
  c3
</td>
h1
c1

It can be fixed by at least removing the blank lines inbetween the inner <tr> / <th> / <td> tags:

<table>
  <tr>
    <th>
      h1
    </th>
    <th>
      h2
    </th>
    <th>
      h3
    </th>
  </tr>
  <tr>
    <td>
      c1
    </td>
    <td>
      c1
    </td>
    <td>
      c3
    </td>
  </tr>
</table>

Thus, this issue's label is being changed to bug.

@EvitanRelta EvitanRelta removed the improve Improvements on existing feature label Dec 12, 2022
@EvitanRelta EvitanRelta self-assigned this Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant