Commit 2d8d267
authored
fix(mdxish): combine code tabs if separated by CLRF token \r\n (#1372)
[![PR App][icn]][demo] | Fix CX-3027
:-------------------:|:----------:
## 🧰 Changes
While investigating
[CX-3027](https://linear.app/readme-io/issue/CX-3027/multi-parameter-set-codetabs-render-as-separate-components-for),
I found that one of the cause of the code tabs separating was because
the raw document had CLRF new line tokens, so \r\n instead of only \n in
between the code blocks. I verified that this resulted in separate code
blocks in mdxish rendering, but seems like it's correctly tabbed in
legacy from looking at the resulting mdast trees.
The adjacency check in the code-tabs transformer only accounted for LF
(\n) line endings. CRLF adds an extra byte (\r) to the offset gap,
causing the check to fail and rendering each code block separately. So I
updated the check to also accept CRLF by allowing a gap of start.column
+ 1 when the blocks are still on consecutive lines (i.e., the extra byte
is \r, not a blank line)/
## 🧬 QA & Testing
Unfortunately, it's quite hard to visually test in an actual doc because
adding in the \r\n in the raw doc will render it literally, and I read
that this might be a Windows os specific thing & not Mac. The best way I
can think of is through the jest tests I created, which includes some
regression tests.
One regression check is to ensure the code blocks behaviour should
follow MDX & legacy, so testing multiple consecutive blocks, adding some
space / characters between the blocks, adding more than 1 line space
between, etc.
- [Broken on production][prod].
- [Working in this PR app][demo].
[demo]: https://markdown-pr-PR_NUMBER.herokuapp.com
[prod]: https://SUBDOMAIN.readme.io
[icn]:
https://user-images.githubusercontent.com/886627/160426047-1bee9488-305a-4145-bb2b-09d8b757d38a.svg1 parent b8d9e4c commit 2d8d267
File tree
2 files changed
+56
-1
lines changed- __tests__/lib/render-mdxish
- processor/transform
2 files changed
+56
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
52 | 74 | | |
53 | 75 | | |
54 | 76 | | |
| |||
161 | 183 | | |
162 | 184 | | |
163 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
164 | 209 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
31 | 38 | | |
32 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
33 | 43 | | |
34 | 44 | | |
35 | 45 | | |
| |||
0 commit comments