PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

HTML <details> tab breaks markdown preview

Open boardtc opened this issue 4 years ago • 18 comments

Adding collapsible section in markdown using html details tag is not supported and all of the embedded markdown in the details tag is shows as is:

Use HTML tag details <details> < summary >Click to expand!< /summary >

  ## Add collapsible section
  1. All of this is shown
  2.  with 
     * no line breaks 
     * or rendering
</ details>

boardtc avatar Jun 17 '20 13:06 boardtc

can you provide a file we can test against?

crutkas avatar Jun 17 '20 18:06 crutkas

Not sure why you don't allow markdown files to be attached, here's it zipped. tester.zip Here's what the preview of it looks like tester preview

boardtc avatar Jun 18 '20 09:06 boardtc

copy of MD. VS Code previews this correctly.

# heading 1

* Departure so attention pronounce satisfied daughters am. But shy tedious pressed studied opinion entered windows off. Advantage 
* dependent suspicion convinced provision him yet. Timed balls match at by rooms we. Fat not boy neat left had with past here call. 
* Court nay merit few nor party learn. Why our year her eyes know even how. Mr immediate remaining conveying allowance do or. 


# A collapsible section with markdown
<details>
  <summary>Click to expand!</summary>
  
## Heading 2
  1. A numbered
  2. list
     * With some
     * Sub bullets
</details>

crutkas avatar Jun 18 '20 16:06 crutkas

Will shifting md preview to monaco resolve this?

franky920920 avatar Dec 13 '21 03:12 franky920920

No since we his is about rendering, Monaco is about viewing

crutkas avatar Dec 13 '21 04:12 crutkas

Is this still an issue with the latest version?

Jay-o-Way avatar Sep 17 '22 13:09 Jay-o-Way

I just tested and it's the same.... on current

boardtc avatar Sep 17 '22 14:09 boardtc

Don't think this is an issue with the actual plug-in, because there is the same result using <details> in comments like this one:

Source text - note the empty lines:

<details><summary>This does not work</summary>
This list:
- contains items
- that will not be
- correctly displayed
</details>
<details><summary>This does work</summary>

This list:
- contains items
- that **will** be
- correctly displayed
</details>

Result

This does not work This list: - contains items - that will not be - correctly displayed
This does work

This list:

  • contains items
  • that will be
  • correctly displayed

Jay-o-Way avatar Sep 17 '22 14:09 Jay-o-Way

@Aaron-Junker do you know anything about the markdown engine?

Jay-o-Way avatar Sep 17 '22 14:09 Jay-o-Way

It is the parsing engine plugin we use. We may be able to swap it out for something else but end of day, the primary goal is to help you see what is in the file, not be a perfect render.

crutkas avatar Sep 17 '22 15:09 crutkas

@crutkas I agree on the (low) priority. But do you know why Github Markdown shows the exact same thing?

Jay-o-Way avatar Sep 17 '22 15:09 Jay-o-Way

Cause they control the parser and rendering :). They can do whatever they want since they control all aspects of how things are interpreted and converted to HTML

crutkas avatar Sep 17 '22 15:09 crutkas

Actually, it's literally mentioned here: https://gist.github.com/scmx/eca72d44afee0113ceb0349dd54a84a2#code 🤓 and here https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d @boardtc looks like you simply need to re-write a bit - the first blank line after closing tag </summary> is the crucial one

Jay-o-Way avatar Sep 17 '22 16:09 Jay-o-Way

Hmmm... I took the sub-heading out and tried the following with the same result, don't think I missed anything? md

boardtc avatar Sep 17 '22 18:09 boardtc

Hmmm... I took the sub-heading out and tried the following with the same result, don't think I missed anything?

Only thing I can think of is the amount of spaces.

1. Item
   * Item

Jay-o-Way avatar Sep 17 '22 20:09 Jay-o-Way

I increased from 2 to 4, it makes no difference :-(

boardtc avatar Sep 17 '22 21:09 boardtc

I increased from 2 to 4, it makes no difference :-(

And 3? The general rule it's that the position of the * must align with the first character of the previous list item.

Jay-o-Way avatar Sep 17 '22 21:09 Jay-o-Way

Since you asked I tested that but the bug is not down to the spaces

boardtc avatar Sep 17 '22 21:09 boardtc