Marp presentations

Patrick Walsh's Avatar

Patrick Walsh

28 Feb, 2023 10:19 PM

Some of my markdown files are intended as presentations. For the last year, I've used marp.app for this purpose. But starting up a local web server and browsing to it is kind of awful. Also though there are flags for watching for changes, this doesn't work for me.

Way better would be to have Marked detect marp (when marp:true is in the frontmatter) and then preprocess the doc accordingly. I'm not as interested in separate presenter view type stuff, though that could be cool, too.

I'm guessing this could be possible using advanced preprocessors. Has anyone tried that? But also would like to ask for Marp support as a feature request.

  1. Support Staff 1 Posted by Brett on 01 Mar, 2023 03:14 PM

    Brett's Avatar

    Does Marp have a command line tool? That's the only real prerequisite for running a custom processor. I don't see adding "official" support for this into Marked, but a custom processor should be a reasonable solution.

    -Brett

    On 28 Feb 2023, at 16:21, Patrick Walsh wrote:

  2. 2 Posted by Patrick Walsh on 02 Mar, 2023 12:13 AM

    Patrick Walsh's Avatar

    It does. Would be awesome if there were official support as I'm fond of busting out quick presentations with markdown and Marked is part of my usual markdown workflow. Regardless, I did mess with this a bit and I have a sorta working solution. For the custom processor:

    tmpfile=$(mktemp /tmp/markdown.XXXXXX)
    cat - >$tmpfile
    if grep -q "marp: true" "$tmpfile"; then
      marp "$tmpfile" -o -
    else
      echo NOCUSTOM
    fi
    rm "$tmpfile"
    

    But the usual themes make the slides tiny. I added a theme called "marp" that makes it display properly and doesn't compete with the styling provided by marp output:

    body {
      padding: 0 !important;
    }
    #wrapper {
      width: 98vw;
      height: 98vh;
      margin: 0;
      padding: 0;
    }
    

    Then I can add the "Marked Style: marp" frontmatter to the markdown so Marked displays it properly. I can even navigate the slides, so that's not half bad.

    The big gap is that changes don't get picked up by Marked. (Or something.) Maybe Marked is reprocessing, but some javascript needs to rerun before the display updates. I am not sure.

    Right now, the best I can do is hit cmd-r in Marked and then arrow back to the slide I was on (cmd-r brings me back to the beginning), which is a bummer.

    Any chance for some help to make these custom hacks work better?

  3. Support Staff 3 Posted by Brett on 03 Mar, 2023 03:21 PM

    Brett's Avatar

    If the failure to update is because JavaScript needs to be triggered, you can use the "hooks" feature to add an update hook. https://marked2app.com/help/Embedding_Scripts.html

    Marked should recognize any change to the source Markdown file, so if you're not at least seeing the little spinner in the lower right activate when you save the file, something else is going wrong. Custom processors do not affect this.

    -Brett

    On 1 Mar 2023, at 18:13, Patrick Walsh wrote:

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac