I'm attempting to duplicate the original img tag's functionality in custom img tag that will be added to the pagedown converter.
e.g I'm copy the original behavior:
![image_url][1] [1]: http://lolink.com gives <img src="http://lolink.com">
into a custom one:
?[image_url][1] [1]: http://lolink.com gives <img class="lol" src="http://lolink.com">
Looking at the docs the only way to do this is through using the preblockgamut hook and then adding another "block level structure." I attempted doing this and got an Uncaught Error: Recursive call to converter.makeHtml
here's the code of me messing around with it:
    converter.hooks.chain("preBlockGamut", function (text, dosomething) {
        return text.replace(/(\?\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, function (whole, inner) {
            return "<img src=" + dosomething(inner) + ">";
        });
    });
I'm not very experienced with hooks and everything so what would I do to fix it? Thanks.
UPDATE: found out that _DoImages runs after prespangamut, will use that instead of preblockgamut
 
                        
Figured it out! The solution is very clunky and involves editing the source code because I am very bad at regex and the
_DoImage()function uses a lot of internal functions only in the source.solution:
All edits will be made to the
markdown.converterfile.do a
ctrl+ffor the_DoImagefunction, you will find that it is named in two places, one in theRunSpanGamutand one defining the function. The solution is simple, copy over theDoImagefunction and related stuff to a new one in order to mimic the original function and edit it to taste.next to
DoImagefunction add:if you look at the difference between the new
_DoPotatoImages()function and the original_DoImages(), you will notice I edited the regex to have an escaped question mark\?instead of the normal exclamation mark!Also notice how the
writePotatoImageTagcallsg_urlsandg_titleswhich are some of the internal functions that are called.After that, add your
text = _DoPotatoImages(text);torunSpanGamutfunction (MAKE SURE YOU ADD IT BEFORE THEtext = _DoAnchors(text);LINE BECAUSE THAT FUNCTION WILL OVERRIDE IMAGE TAGS) and now you should be able to write?[image desc](url)along withdone.