Convert certain HTML pastes to Markdown #52
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR would allow certain HTML pastes to be converted to Markdown automatically in input forms where markdown is supported. This would be especially helpful for tables.
The first commit is a very simple, clumsy sample using html2md. When pasting, the handle_paste function gets the
text/html
value. It checks for a tag indicating it came from Excel, grabs the content from<table>
to</table>
and runs it through the html2md parse_html function to get the markdown equivalent.I haven't looked too much into how robust html2md is for generating markdown (seems to cover original basics), but we might need to extend it or use html5ever to do it ourselves. This will take some looking into.
This requires
rustflags=["--cfg=web_sys_unstable_apis"]
due to the use of ClipboardEvent, but this results in dependencies being recompiled on each run. This would need to be fixed somehow before merging.