dendronhq / dendron

The personal knowledge management (PKM) tool that grows as you do!
https://wiki.dendron.so
Apache License 2.0
6.69k stars 253 forks source link

Markdown Tables Not Rendering Inside Data Definitions with Markdown Preview Enhanced v0.10.15 #428

Open FrancoB411 opened 3 years ago

FrancoB411 commented 3 years ago

Describe the bug Markdown Tables Inside Data Definitions Not Rendering in Markdown Preview Enhanced v0.10.15

Before a recent update, tables rendered inside data definitions the way Pandoc does. The new version no longer renders the tables when they are nested inside data definitions. Left aligned tables still render

To Reproduce Steps to reproduce the behavior:

  1. Create a test_1.md file with "Left Aligned table for test_1.md" sample text below. (See Additional Context)
  2. The table should render properly like in screenshot example 1.
  3. Create a test_2.md file with "Nested table inside a data definition" sample text below. (See Additional Context)
  4. The table should not render properly, like in screenshot example 2.
  5. Install Pandoc and render the file pandoc test_2.md -s --mathjax -o test_2.html && open test_2.html
  6. You should a render that looks like screenshot example 3

Expected behavior Markdown preview should render a table inside a data definition the way pandoc does. Instead, it only renders tables when they are left aligned

Screenshots

Example 1, Left aligned table renders properly:

Screen Shot 2020-12-27 at 11 53 34 PM

Example 2, table inside a data definition does not render properly:

Screen Shot 2020-12-27 at 11 37 25 PM

Example 3, table inside data definition rendered with Pandoc renders properly

Screen Shot 2020-12-27 at 11 39 24 PM

Desktop (please complete the following information): VsCode Version: 1.52.1 Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523 Date: 2020-12-16T16:30:02.420Z (1 wk ago) Electron: 9.3.5 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Darwin x64 18.7.0 Dendron Markdown Preview Enhanced: v0.10.15

Additional context

Left Aligned table for test_1.md sample text:

| |  $H_0$ True |  $H_0$ False | |
|--|--|--|--| 
| reject | Type I | | 100% |
| not reject |  | Type II | 100% | 
| | 100% | 100%||

Nested table inside a data definition for test_2.md sample text:

Type I and Type II Error
  ~ | |  $H_0$ True |  $H_0$ False | |
    |--|--|--|--| 
    | reject | Type I | | 100% |
    | not reject |  | Type II | 100% | 
    | | 100% | 100%||

Dendron Log file {"level":30,"time":1609130201204,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"Logger:configure","msg":"exit","log_level":"info"} {"level":30,"time":1609130201220,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","stage":"dev","isDebug":false,"logPath":"/Users/franco/Library/Application Support/Code/logs/20201226T125147/exthost1/dendron.dendron","logLevel":"info","extensionPath":"/Users/franco/.vscode/extensions/dendron.dendron-0.21.0","extensionUri":{"$mid":1,"fsPath":"/Users/franco/.vscode/extensions/dendron.dendron-0.21.0","path":"/Users/franco/.vscode/extensions/dendron.dendron-0.21.0","scheme":"file"},"storagePath":"/Users/franco/Library/Application Support/Code/User/workspaceStorage/7fbb629df4efaf03258241407eedda10/dendron.dendron","workspaceFile":{"$mid":1,"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/dendron.code-workspace","external":"file:///Users/franco/Google%20Drive/CS%20Curriculum/Notes/Dendron%20Notes/dendron.code-workspace","path":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/dendron.code-workspace","scheme":"file"},"workspaceFolders":[{"uri":{"$mid":1,"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault","external":"file:///Users/franco/Google%20Drive/CS%20Curriculum/Notes/Dendron%20Notes/vault","path":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault","scheme":"file"},"name":"vault","index":0}]} {"level":30,"time":1609130201224,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"DendronWorkspace","msg":"initialized"} {"level":30,"time":1609130201231,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","config":{"version":1,"vaults":[{"fsPath":"vault"}],"site":{"copyAssets":true,"siteHierarchies":["root"],"siteRootDir":"docs","usePrettyRefs":true}},"configMigrated":false,"msg":"read dendron config"} {"level":30,"time":1609130204333,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","wsConfig":{"folders":[{"path":"vault"}],"settings":{"dendron.rootDir":".","files.autoSave":"onFocusChange","pasteImage.path":"${currentFileDir}/assets/images","pasteImage.prefix":"/","markdown-preview-enhanced.enableWikiLinkSyntax":true,"markdown-preview-enhanced.wikiLinkFileExtension":".md","editor.snippetSuggestions":"inline","editor.suggest.snippetsPreventQuickSuggestions":false,"editor.suggest.showSnippets":true,"editor.tabCompletion":"on"},"extensions":{"recommendations":["dendron.dendron-paste-image","equinusocio.vsc-material-theme","dendron.dendron-markdown-shortcuts","dendron.dendron-markdown-preview-enhanced","dendron.dendron-markdown-links","github.github-vscode-theme"],"unwantedRecommendations":["dendron.dendron-markdown-notes","shd101wyy.markdown-preview-enhanced","kortina.vscode-markdown-notes","mushan.vscode-paste-image"]}},"wsConfigMigrated":{},"msg":"read wsConfig"} {"level":30,"time":1609130204339,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","installedGlobalVersion":"0.21.0","migratedGlobalVersion":"0.21.0","previousGlobalVersion":"0.20.0","previousWsVersion":"0.21.0","platform":"darwin","extensions":[{"id":"dendron.dendron-paste-image","version":"1.0.4","active":false},{"id":"equinusocio.vsc-material-theme","version":"33.1.2","active":false},{"id":"dendron.dendron-markdown-shortcuts","version":"0.12.1","active":true},{"id":"dendron.dendron-markdown-preview-enhanced","version":"0.10.15","active":false},{"id":"dendron.dendron-markdown-links","version":"0.6.17","active":false},{"id":"github.github-vscode-theme","version":"1.1.5","active":false}],"vaults":[{"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault"}]} {"level":30,"time":1609130204340,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"startServeer","logLevel":"info"} {"level":30,"time":1609130204359,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","msg":"post-start-server","port":51532} {"level":30,"time":1609130204361,"pid":80768,"hostname":"francombp.local","ctx":"FileStorageV2","wsRoot":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes","vaultsv3":[{"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault"}]} {"level":30,"time":1609130204362,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"ReloadIndex.execute","msg":"enter"} {"level":30,"time":1609130204394,"pid":80768,"hostname":"francombp.local","ctx":"FileStorageV2","wsRoot":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes","vaultsv3":[{"fsPath":"vault"}]} {"level":30,"time":1609130205638,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"ReloadIndex.execute","msg":"exit"} {"level":30,"time":1609130205638,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"reloadWorkspace","msg":"post-ws.reloadWorkspace"} {"level":30,"time":1609130205639,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"reloadWorkspace","msg":"exit"} {"level":30,"time":1609130205640,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"postReloadWorkspace","msg":"same wsVersion"} {"level":30,"time":1609130205640,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"postReloadWorkspace","msg":"exit"} {"level":30,"time":1609130205641,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"TreeView:getChildren","msg":"reconstructing tree"} {"level":30,"time":1609130205642,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"setupViews","msg":"init:backlinks"} {"level":30,"time":1609130205644,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"activateWorkspace","stage":"dev","msg":"enter"} {"level":30,"time":1609130205651,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"toggleViews","msg":"views enabled: true"} {"level":30,"time":1609130205651,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"_activate","msg":"fin startClient"} {"level":30,"time":1609130205652,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"showWelcomeOrWhatsNew","version":"0.21.0","previousVersion":"0.21.0"} {"level":30,"time":1609130205652,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"showWelcomeOrWhatsNew","msg":"not first time install"} {"level":30,"time":1609130313570,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WorkspaceWatcher:onWillSaveTextDocument","url":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","reason":1,"msg":"enter"} {"level":30,"time":1609130313572,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WorkspaceWatcher:onWillSaveTextDocument","match":["updated: 1609013795755"],"msg":"update activeText editor"} {"level":30,"time":1609130314780,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"VaultWatcher:onDidChange","uri":{"$mid":1,"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","path":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","scheme":"file"}} {"level":30,"time":1609130314907,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"VaultWatcher:onDidChange","fname":"probability-statistics","msg":"exit"} {"level":30,"time":1609130796976,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WorkspaceWatcher:onWillSaveTextDocument","url":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","reason":1,"msg":"enter"} {"level":30,"time":1609130796980,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WorkspaceWatcher:onWillSaveTextDocument","match":["updated: 1609130313571"],"msg":"update activeText editor"} {"level":30,"time":1609130798402,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"VaultWatcher:onDidChange","uri":{"$mid":1,"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","path":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","scheme":"file"}} {"level":30,"time":1609130798593,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"VaultWatcher:onDidChange","fname":"probability-statistics","msg":"exit"} {"level":30,"time":1609131982675,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WindowWatcher:onDidChangeActiveTextEditor","msg":"enter","uri":{"$mid":1,"fsPath":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","external":"file:///Users/franco/Google%20Drive/CS%20Curriculum/Notes/Dendron%20Notes/vault/probability-statistics.md","path":"/Users/franco/Google Drive/CS Curriculum/Notes/Dendron Notes/vault/probability-statistics.md","scheme":"file"}} {"level":30,"time":1609131991130,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"c:run","msg":"pre-execute"} {"level":30,"time":1609131991130,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"execute","opts":{}} {"level":30,"time":1609131991163,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"c:run","msg":"post-execute"} {"level":30,"time":1609131991352,"pid":80768,"hostname":"francombp.local","name":"dendron","ctx":"WindowWatcher:onDidChangeActiveTextEditor","msg":"enter","uri":{"$mid":1,"fsPath":"/Users/franco/Library/Application Support/Code/logs/20201226T125147/exthost1/dendron.dendron/dendron.log","external":"file:///Users/franco/Library/Application%20Support/Code/logs/20201226T125147/exthost1/dendron.dendron/dendron.log","path":"/Users/franco/Library/Application Support/Code/logs/20201226T125147/exthost1/dendron.dendron/dendron.log","scheme":"file"}}

kpathakota commented 3 years ago
Still repros but one datapoint that prettier formats the 2nd version of the table as: ~ $H_0$ True $H_0$ False
reject Type I 100%
not reject Type II 100%
100% 100%

So this isn't properly recognized markdown syntax. That said, we should consider this when updating to a Dendron unified previewer (#643)

FrancoB411 commented 3 years ago

Php markdown extra as part of its spec allows the arbitrary inclusion of block elements inside definition lists. Docs Which allowed in html so one would expect markdown behavior to enable the same.

FrancoB411 commented 3 years ago

Saw that this issue was still open and part of an Epic now, so I figured I'd add in some test cases showing the differences between Dendron and the reference renderers.

After looking into this a little more, Based on Babelmark 2, Pandoc seems like a good target, as it seems to be the library some of the JS parsers, including Markdown-it attempt to emulate.

Bug Report

The Dendron Markdown Markdown-it based preview does not match the the Pandoc 2.14.2 Demo, and in some cases, the [Markdown-it Demo]().

In some cases, this appears to be a markdown-it issue, as the stated goal of Markdown-it is to match pandoc's spec. In other cases it appears to be a Dendron issue, where Dendron's output does not match either Markdown-it or Pandoc.

TODO: Test requiring markdown-it-deflist plugin

Tests

Renders ordered list as a block in the data definition when the first definition line is blank

Input

Renders an ordered list as a definition ~

  1. item1
  2. item2
  3. item3
Expected

Definition list should match Pandoc Demo

<dl>
<dt>renders ordered list as definition</dt>
<dd><ol type="1">
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ol>
</dd>
</dl>
Actual

Dendron Preview Render matches the Markdown-it Demo and fails to parse the definition and the block level sub element

<p>renders ordered list as definition<br>
~</p>
<ol>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ol>

Renders ordered list as a block in the data definition when the first definition line is NOT blank

Input

Renders an ordered list as a definition ~ Definition not blank

1. item1
2. item2
3. item3
Expected

Definition list should match Pandoc Demo

<dl>
<dt>Renders an ordered list as a definition</dt>
<dd><p>Definition not blank</p>
<ol type="1">
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ol>
</dd>
</dl>
Actual

Dendron Preview Render fails to parse the list as a block level definition sub element, and instead renders it as code.

<dl>
<dt>Renders an ordered list as a definition</dt>
<dd>Definition not blank</dd>
</dl>
<pre data-role="codeBlock" data-info="" class="language-"><code>1. item1
2. item2
3. item3
</code></pre>

Markdown-it Demo parses the list a block level sub element of the definition but omits Pandoc's type="1" attribute

<dl>
<dt>Renders an ordered list as a definition</dt>
<dd>
<p>Definition not blank</p>
<ol>
<li>item1</li>
<li>item2</li>
<li>item3</li>
</ol>
</dd>
</dl>

Renders Table as a block in the data definition

Input

Renders a block level table in a definition-list ~ Definition with a table

| head1 | head2 |
|---+---|
| td | td | 
Expected

Definition list should match Pandoc Demo

<dl>
<dt>Renders a block level table in a definition-list</dt>
<dd><p>Definition with a table</p>
<table>
<thead>
<tr class="header">
<th>head1</th>
<th>head2</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>td</td>
<td>td</td>
</tr>
</tbody>
</table>
</dd>
</dl>
Actual

Dendron Preview Render fails to parse the table as a block level definition sub element, and instead renders it as code.

<dl>
<dt>Renders a block level table in a definition-list</dt>
<dd>Definition with a table</dd>
</dl>
<pre data-role="codeBlock" data-info="" class="language-"><code>| head1 | head2 |
|---+---|
| td | td | 
</code></pre>

Markdown-it Demo parses table outside the definition list

<dl>
<dt>Renders a block level table in a definition-list</dt>
<dd>
<p>Definition with a table</p>
<p>| head1 | head2 |
|—±–|
| td | td |</p>
</dd>
</dl>
aleksey-rowan commented 2 years ago

@FrancoB411, Dendron is no longer using Markdown Preview Enhanced for Markdown rendering. Could you please check if the issues you are describing are still present in the new preview?

FrancoB411 commented 2 years ago

Yes. What version of dendron made the change? Can I just restart vs code?

On Thu, Feb 17, 2022, 2:46 PM Aleksey Rowan @.***> wrote:

@FrancoB411 https://github.com/FrancoB411, Dendron is no longer using Markdown Preview Enhanced for Markdown rendering. Could you please check if the issues you are describing are still present in the new preview?

— Reply to this email directly, view it on GitHub https://github.com/dendronhq/dendron/issues/428#issuecomment-1043353620, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACOI35O5DQT2KAS4GY2VJLU3VGBLANCNFSM4VLRIFOQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

aleksey-rowan commented 2 years ago

It switched some time ago and the new preview is automatically enabled for newly initialized workspaces/vaults. For an existing one, add enablePreviewV2: true under dev in your dendron.yml.

// dendron.yml
dev:
    enablePreviewV2: true

The only reference in the docs to this setting that I could find is here: https://wiki.dendron.so/notes/Tf4vuVLV3rSdpzD8la9FP/#preview-v2-enhancements

FrancoB411 commented 2 years ago

The issue persists. Steps I took: Restarted VS Code. Dendron Running vs 0.82.0 Checked dendron.yml has enablePreview: true in dev

Tried previewing the same file used to report the original bug.

In the current preview, the

However, unlike markdown preview enhanced, I could not find an option to save the preview as an HTML and see if this is a styling or parsing issue.

The debug markdown test file file in case you want to render it.

And the preview screenshots below: The red arrow indicates the definition list not rendering properly in the preview

Preview

Two red arrows indicate the tables not rendering. NOTE: I duplicated the table to render it outside the definition list. The debug markdown test file above does not have the duplicated table. Just the one in the definition list.

Screen Shot 2022-02-21 at 3 25 50 PM