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

Formatted tables and strikethrough text in Pad .md exports #1720

Merged
merged 12 commits into from
Dec 12, 2024

Conversation

zuzanna-maria
Copy link
Contributor

@zuzanna-maria zuzanna-maria linked an issue Nov 22, 2024 that may be closed by this pull request
@zuzanna-maria zuzanna-maria added the Ready to Review This PR is ready to be checked by another team member label Nov 22, 2024
@zuzanna-maria zuzanna-maria self-assigned this Nov 22, 2024
@yflory yflory removed the Ready to Review This PR is ready to be checked by another team member label Dec 4, 2024
@zuzanna-maria zuzanna-maria added the Ready to Review This PR is ready to be checked by another team member label Dec 5, 2024
@@ -96,7 +96,34 @@ define([
if (ext === ".md") {
var md = Turndown({
headingStyle: 'atx'
}).turndown(toExport);
}).addRule('table', {
filter: ['tr'],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small indentation issue starting here

replacement: function (content, node) {
var indexOf = Array.prototype.indexOf;
var index = indexOf.call(node.parentNode.childNodes, node);
var rowContent = node.innerHTML.replace(/<td>/g, '').replace(/<br>/g, ' ').split('</td>');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Removing the <br> here will remove new lines inside cells. This is acceptable since currently exports are not working but it would be nice to be able to fix this.
  2. This won't work if the table contains "header" cells which are <th> instead of <td>
  3. I think it would be easier to work with the DOM elements directly instead of treating the HTML as a string

@yflory yflory added Ready to Test This PR is ready to be tested and removed Ready to Review This PR is ready to be checked by another team member labels Dec 9, 2024
@davidbenque
Copy link
Contributor

The markdown tables seem to be missing a pipe character at the start of rows that have content, and at the end of the empty row after the header.

The CryptPad Code app seems to render the table anyways, but other apps might not (I tested Typora which didn't work). Github also seems to be fine with the example below, so maybe this is a niche issue with the apps I use and my way of writing tables.

original Rich Text table:
image

Markdown export:

test in|value **number** (kg)|Date|
|-|-|-
_yes_|<u>this is a weird one</u>|2024|
no|old option is ~not valid~ anymore|2025|

Rendered on GitHub:

test in value number (kg) Date
yes this is a weird one 2024
no old option is not valid anymore 2025

@yflory yflory merged commit 3704575 into staging Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to Test This PR is ready to be tested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Exporting tables to markdown does not work
3 participants