goldmark/_test/extra.txt
Karel Bilek 7cdc0fb06f Fix leading tabs with codeblocks
Note that this is a breaking change and will require new goldmark major version.

I have tried to fix problem with leading tabs in fenced code blocks (and probably normal code blocks too).

Important note - tabs do not behave like "just 4 spaces". They "finish" 4 space columns. So tab can behave like anything between 1 space to 4 spaces, depending on position.

If you have MD like this (. represents space, [tb] , [t] or [] tabs)

```
*.some.text
..```
..foo
..[]foo
..```
```

you expect the tab to be kept in the code. This did not work properly in goldmark and I fixed that.

However, if you have a code like this

```
*.some.text
..```
..foo
.[t]foo
..```
```

what should happen? I decided that it should be two spaces, as the tab is not "completely" in the code block. Similarly, what should happen in this case

```
*.some.text
..```
..foo
.[t][tb]foo
..```
```

I decided that it should be first three spaces and then tab. Not sure what even is the correct solution here...

The crux of the fix is - text segments don't have just padding, but also remember what chars is the padding and then print that, if they are called to do so in the code blocks. In other cases, the paddingChars are ignored.

This should fix #177 .
2021-01-29 14:55:55 +07:00

218 lines
3.6 KiB
Text

1
//- - - - - - - - -//
* A
B
//- - - - - - - - -//
<ul>
<li>A
B</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//
2
//- - - - - - - - -//
**test**\
test**test**\
**test**test\
test**test**
//- - - - - - - - -//
<p><strong>test</strong><br />
test<strong>test</strong><br />
<strong>test</strong>test<br />
test<strong>test</strong></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
3
//- - - - - - - - -//
>* >
> 1
> 2
>3
//- - - - - - - - -//
<blockquote>
<ul>
<li>
<blockquote>
</blockquote>
</li>
</ul>
<p>1
2
3</p>
</blockquote>
//= = = = = = = = = = = = = = = = = = = = = = = =//
4
//- - - - - - - - -//
`test`a`test`
//- - - - - - - - -//
<p><code>test</code>a<code>test</code></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
5
//- - - - - - - - -//
_**TL/DR** - [Go see summary.](#my-summary-area)_
//- - - - - - - - -//
<p><em><strong>TL/DR</strong> - <a href="#my-summary-area">Go see summary.</a></em></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
6
//- - - - - - - - -//
[This link won't be rendered
correctly](https://geeksocket.in/some-long-link-here "This is the
place where everything breaks")
//- - - - - - - - -//
<p><a href="https://geeksocket.in/some-long-link-here" title="This is the
place where everything breaks">This link won't be rendered
correctly</a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
7
//- - - - - - - - -//
[](./target.md)
//- - - - - - - - -//
<p><a href="./target.md"></a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
8
//- - - - - - - - -//
[]()
//- - - - - - - - -//
<p><a href=""></a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
9
//- - - - - - - - -//
[daß] is the old german spelling of [dass]
[daß]: www.das-dass.de
//- - - - - - - - -//
<p><a href="www.das-dass.de">daß</a> is the old german spelling of <a href="www.das-dass.de">dass</a></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
10
//- - - - - - - - -//
1. First step.
~~~
aaa
---
bbb
~~~
2. few other steps.
//- - - - - - - - -//
<ol>
<li>
<p>First step.</p>
<pre><code>aaa
---
bbb
</code></pre>
</li>
<li>
<p>few other steps.</p>
</li>
</ol>
//= = = = = = = = = = = = = = = = = = = = = = = =//
11: delimiters between ascii punctuations should be parsed
//- - - - - - - - -//
`{%`_name_`%}`
//- - - - - - - - -//
<p><code>{%</code><em>name</em><code>%}</code></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
12: the alt attribute of img should be escaped
//- - - - - - - - -//
!["](quot.jpg)
!['](apos.jpg)
![<](lt.jpg)
![>](gt.jpg)
![&](amp.jpg)
//- - - - - - - - -//
<p><img src="quot.jpg" alt="&quot;" />
<img src="apos.jpg" alt="'" />
<img src="lt.jpg" alt="&lt;" />
<img src="gt.jpg" alt="&gt;" />
<img src="amp.jpg" alt="&amp;" /></p>
//= = = = = = = = = = = = = = = = = = = = = = = =//
13: fenced code block starting with tab inside list
//- - - - - - - - -//
* foo
```Makefile
foo
foo
```
//- - - - - - - - -//
<ul>
<li>foo
<pre><code class="language-Makefile">foo
foo
</code></pre>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//
14: fenced code block inside list, mismatched tab start
//- - - - - - - - -//
* foo
```Makefile
foo
foo
```
//- - - - - - - - -//
<ul>
<li>foo
<pre><code class="language-Makefile">foo
foo
</code></pre>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//
15: fenced code block inside nested list
//- - - - - - - - -//
* foo
- bar
```Makefile
foo
foo
```
//- - - - - - - - -//
<ul>
<li>foo
<ul>
<li>bar
<pre><code class="language-Makefile">foo
foo
</code></pre>
</li>
</ul>
</li>
</ul>
//= = = = = = = = = = = = = = = = = = = = = = = =//