How do I enable ::highlighting:: in Marked 2?

patrickgilmour's Avatar

patrickgilmour

20 Nov, 2017 04:24 PM

In a couple of text editors I use (Bear, Ulysses) I can use ::this highlighting syntax::

In the above, the 'this highlighting syntax' will appear as if highlighted by a highlighting pen.

It's a feature I use a lot but I don't see Marked 2 converting ::text:: to highlighted.

Is there a way to enable this?

Thanks,

Pat

  1. Support Staff 1 Posted by Brett on 20 Nov, 2017 05:32 PM

    Brett's Avatar

    This isn't Markdown syntax in any flavor that I know of, I assume it's
    specific to Bear and Ulysses, both of which implement their own
    variation of Markdown. Generally in Markdown, you'd use the html
    `<mark>` tag to highlight text, but it would also be possible to use a
    custom preprocessor to do the replacement automatically.

    -Brett

  2. 2 Posted by patrickgilmour on 21 Nov, 2017 01:41 PM

    patrickgilmour's Avatar

    Brett - thanks for the answer!

    I'm assuming I should take a look here. Hopefully, I can get my head around it:
    http://marked2app.com/help/Custom_Processor.html

    Will post back, if I do.

    Pat

  3. Support Staff 3 Posted by Brett on 21 Nov, 2017 08:49 PM

    Brett's Avatar

    The preprocessor could be pretty simple. The code below can be saved to a file, made executable, and run as a preprocessor (see the docs for more detail):

    #!/bin/bash
    cat | sed -E 's/::[[:alnum:]](.*)[[:alnum:]]::/<mark>\1<\/mark>/g'
    
  4. 4 Posted by patrickgilmour on 22 Nov, 2017 01:47 PM

    patrickgilmour's Avatar

    Thanks for sharing that!

    I created the file as marked-comment-highlight.sh and used chmod +x on it.

    I get the error:

    ERROR: Custom processor is not executable Please ensure that your user has permission to execute marked-comment-highlight.sh

    I assume this means I need the non-MAS version of Marked 2, so I've requested the cross-grade as per the instructions in the error dialog. Is that the right step?

  5. Support Staff 5 Posted by Brett on 22 Nov, 2017 05:00 PM

    Brett's Avatar

    I would first try this:

    Set the preprocessor to /bin/bash

    Then set the argument to the path to the script

    -Brett

  6. 6 Posted by patrickgilmour on 23 Nov, 2017 12:05 AM

    patrickgilmour's Avatar

    Very sensible advice ;-)

    I did as you suggest and things worked better, though I still wasn't at liberty to choose where I wanted my script to live. Moving to the non-MAS version fixed that--thanks for sending over the new license!

    One thing, the regex in the script matches: ::[[:alnum:]](.*)[[:alnum:]]:: then wraps a mark tag round the wildcard group. This means the first character fo the string was being removed. It also meant that if the marked text started with anything other than alphanumeric text, it didn't mark.

    I changed the search string to the very greedy ::(.*):: and for everything I've tried so far, it seems to work. Maybe pitfalls await, but so far, so good.

    Thanks for you help!

  7. Support Staff 7 Posted by Brett on 23 Nov, 2017 02:45 AM

    Brett's Avatar

    Good call, didn't test that :). You could also just move the parens around the alnum groups.

    Thanks,
    Brett

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