-
-
Notifications
You must be signed in to change notification settings - Fork 656
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
Conversation
zuzanna-maria
commented
Nov 22, 2024
- Pad documents exported in .md format now include table and strikethrough text formatting (fixes Exporting tables to markdown does not work #1531)
www/pad/export.js
Outdated
@@ -96,7 +96,34 @@ define([ | |||
if (ext === ".md") { | |||
var md = Turndown({ | |||
headingStyle: 'atx' | |||
}).turndown(toExport); | |||
}).addRule('table', { | |||
filter: ['tr'], |
There was a problem hiding this comment.
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
www/pad/export.js
Outdated
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>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- 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. - This won't work if the table contains "header" cells which are
<th>
instead of<td>
- I think it would be easier to work with the DOM elements directly instead of treating the HTML as a string
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. Markdown export:
Rendered on GitHub:
|