Define target attribute for <a> tags?

davidjohnmacdonald's Avatar

davidjohnmacdonald

23 Aug, 2013 01:54 PM

I mostly use Marked to generate HTML files that are then used in iframes. I would like the links in those iframes to open either in the parent window or a new tab. Is it possible to tell Marked that all of my links should have either target=_blank or target=_parent?

  1. Support Staff 1 Posted by Brett on 23 Aug, 2013 02:07 PM

    Brett's Avatar

    This would be best handled with JavaScript. You can add such attributes using reference links in MultiMarkdown, but you'd have to do it for each one. The best option is to have a JavaScript that intercepts links (onclick) and forces them to open in new windows. If you need help writing something like that, let me know.

    -Brett

  2. 2 Posted by davidjohnmacdon... on 23 Aug, 2013 03:49 PM

    davidjohnmacdonald's Avatar

    Thanks for the quick response. I instead wrote a Javascript that adds an attribute to all a tags called by window.onload. Is there a way I can ask Marked to default to *not* "include preview template on export"? It's just that I'm forgetful.

  3. Support Staff 3 Posted by Brett on 23 Aug, 2013 03:58 PM

    Brett's Avatar

    Marked should remember your last setting for style inclusion, is that not happening?

  4. 4 Posted by davidjohnmacdon... on 23 Aug, 2013 04:02 PM

    davidjohnmacdonald's Avatar

    It remembers within the session only.

    If I close and re-open Marked, it returns to the default setting when I save.

  5. Support Staff 5 Posted by Brett on 23 Aug, 2013 04:05 PM

    Brett's Avatar

    I'll fix that as soon as I can.

    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