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

Include text/html using markdown and pandoc #549

Closed
dnebauer opened this issue Sep 9, 2018 · 12 comments
Closed

Include text/html using markdown and pandoc #549

dnebauer opened this issue Sep 9, 2018 · 12 comments

Comments

@dnebauer
Copy link

dnebauer commented Sep 9, 2018

Found a fascinating conversation on Hacker News about scripting mutt to include a html message in outgoing email, as well as plaintext, by writing emails in markdown and having pandoc convert it to standlone html prior to sending (see here, and here for the full thread).

Is there any way for astroid users to do something similar using its current capabilities, i.e., without having to patch astroid itself?

@gauteh
Copy link
Member

gauteh commented Sep 9, 2018 via email

@dnebauer
Copy link
Author

dnebauer commented Sep 9, 2018

Not sure what you mean by "markdown switch in composer" -- can you point me to anywhere with more information (wiki? github pages?). Does this switch, whatever it is, control whether an html part is included in outgoing messages?

By "See config if using custom processor" do you mean the editor.markdown_processor config option? I see from #541 that jonassmedegaard found that the markdown processors cmark, markdown, discount, python-markdown, pandoc, and marked all worked on quick testing. I'm not sure I get the relevance, however, as choice of markdown processor has no influence on whether an html part is included in outgoing messages (at least as far as I can see).

@gauteh
Copy link
Member

gauteh commented Sep 10, 2018

See this issue: #430, is that what you mean?

You can write your e-mail as normal, but with markdown formatting. If you flip the Markdown switch on the e-mail will be written as two parts: the raw message as text/plain and a processed text/html part which has been piped through cmark (or the processor of your choice). Make sure you have it installed.

Note that there are some preview issues: #532

@dnebauer
Copy link
Author

This feels like one of those conversations where everybody else knows something I don't. My new message window does not have a markdown switch:

astroid_new_message

Here is the editor section of my config file:

    "editor": {
        "cmd": "gvim -geom 10x10 --servername %2 --socketid %3 -f '+set ft=mail' '+set fileencoding=utf-8' '+set ff=unix' '+set enc=utf-8' '+set fo+=w' '+/^To:/' '+startinsert!' %1",
        "external_editor": "false",
        "charset": "utf-8",
        "save_draft_on_force_quit": "true",
        "attachment_words": "attach",
        "attachment_directory": "~",
        "markdown_processor": "cmark"
    },

I've also tried marked and pandoc as markdown processors, with not effect. The processors cmark, marked and pandoc are all installed.

Is there some step I have to take to enable the markdown switch? Maybe this feature is available with editors other than gvim?

@gauteh
Copy link
Member

gauteh commented Sep 10, 2018 via email

@dnebauer
Copy link
Author

First, *doh*, I've sent hundreds of emails using astroid and can't believe I never noticed the Markdown and Signature switches on the preview window. Talk about inattentional blindness...

Second, *sigh*, that just leads to another problem. When I toggle the Markdown switch the html display is suppressed, with an "Alternative part (type: text/html) - potentially sketchy" widget appearing in its place:

astroid_md-switch

This is the usual behaviour when displaying emails, and in those cases I can open the html part by moving focus to the "sketchy" widget with Ctrl-j and opening it by pressing Enter on my keyboard. When previewing an outbound email, I can jump to the "sketchy" widget with Ctrl-j as usual but the Enter key press is intercepted and used to open the email once again for editing. According to #19 it should be possible to open the "sketchy" widget with the 'o' key when it has focus, but in preview mode this has no effect (nor does pressing capital 'O').

I experimented with the thread_view.preferred_type and thread_view.preferred_html_only settings but they made no difference in preview mode. It also made no difference whether I used internal gvim or external gvim to edit emails.

Is there any way to open the html part in preview mode? (I'm sure it's ridiculously easy when you know the trick.)

Is there any way to ensure that html displays by default in preview mode?

I should add that I've checked the raw email using 'V' and the html part is present and correct.

@gauteh
Copy link
Member

gauteh commented Sep 11, 2018 via email

@dnebauer
Copy link
Author

dnebauer commented Sep 11, 2018

Ctrl-Space opens the "sketchy" widget and opens the html part in EditMode on my current astroid! (Note that this is version 0.11.1):

astroid_html-part

If it's not working for you, and you are using a current version of astroid, then it would seem to be a relatively new bug.

@dnebauer
Copy link
Author

I should point out that the original issue reported here -- writing plain text emails in markdown and including an html part in the resulting email -- has been resolved.

The remaining problem is getting the html part to always display in the preview. It currently takes 5 key presses to show: M (Markdown switch), Ctrl-j (to move focus to "sketchy" widget) and Ctrl-Space (to open html part). That is annoying if you want to routinely preview html output, which I do. If I'm reading it correctly, though, #532 is addressing this problem so I'll subscribe to it and close this issue.

Thanks for your prompt replies throughout this issue and, as always, thanks for astroid.

@gauteh
Copy link
Member

gauteh commented Sep 11, 2018 via email

@dnebauer
Copy link
Author

Please add my vote to making it possible to configure the Markdown switch to be on by default.

@gauteh
Copy link
Member

gauteh commented Oct 19, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants