ShurK / pagedown

Automatically exported from code.google.com/p/pagedown
Other
0 stars 0 forks source link

Better hooks. postHashHtmlBlocks maybe? #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Pretty simple really. Currently it's a pain to extend pagedown without forking 
and modifying the source. It would be nice to have more hooks to play with.

It seems unlikely you guys will add Markdown Extra support in the near future, 
so it's really the least you could do to help me out a little in my efforts. 
I'm trying to do it purely as a plugin, making use of the current pre/post 
conversion hooks, but it results in a lot of ugly hacks and duplicated code.

It would be awesome if you could add a new hook right after hashHTMLBlocks. 
Then I could rely on the fact that block-level tags are hashed and tabs / line 
endings are normalized (which I can't do in the preConversion hook), and I 
wouldn't have to worry about the Markdown Converter having already parsed / 
misinterpreted the Markdown Extra syntax (which I can't do in the 
postConversion hook).

Not honoring this request will almost certainly be interpreted as proof that 
pagedown was released to the open source community only as a source of free 
labor and geek cred for StackOverflow. Your call. ;)

Original issue reported on code.google.com by jmcm...@gmail.com on 2 Feb 2013 at 5:29

GoogleCodeExporter commented 8 years ago
I was about to clone and submit a patch, but that seems like far too much work 
for such a small change. Here:

line 110:
   pluginHooks.addNoop("postNormalization"); // called once all normalizations have    been completed, but before any conversions have taken place

line 174:
  text = pluginHooks.postNormalization(text);

Pretty please?

Original comment by jmcm...@gmail.com on 2 Feb 2013 at 5:56

GoogleCodeExporter commented 8 years ago
I read the title of the request and the first few sentences and I thought, 
"Hey, that's a great point, a good idea, and a simple change."

And then I reached your threat at the bottom (and don't tell me that the 
emoticon changes anything). I am not one to feed trolling attempts, so I will 
not respond to your ridiculous accusations. I actually liked that you added the 
Markdown Extra plugins, and I made people aware of it 
(https://twitter.com/balpha/status/296542542479126528); I even spent some time 
looking for a Twitter account of yours for crediting you directly, but I 
couldn't find one.

For a believer in the FOSS movement and someone who loves working with good and 
great people at Stack Overflow, such a sentence is a punch in the face. You 
know, we're actual human beings (http://stackexchange.com/about/team).

The plugin hook is a good idea. I'll add it, and maybe a few more while I'm at 
it. Have a nice day.

Original comment by b...@stackoverflow.com on 2 Feb 2013 at 7:54

GoogleCodeExporter commented 8 years ago
Great! Looking forward to it.

The twitter handle is justin_mcmanus. I don't use it regularly.

The pseudo-jab was just meant as lighthearted motivation. If I had know you 
were such an awesome dude, well, I probably still would've said it because I'm 
kind of an asshole. <3

And emoticons change everything, by the way.

Original comment by jmcm...@gmail.com on 2 Feb 2013 at 4:56

GoogleCodeExporter commented 8 years ago
http://code.google.com/p/pagedown/source/detail?r=99d062846dd8c1a100500d09cd5991
338f533516 adds several hooks to the converter. The one requested here is not 
included, since I don't think a hook between _HashHTMLBlocks and 
_StripLinkDefinitions is really helpful. I still think this change fulfills 
this request in spirit.

Either all you want is the normalized source, for which there is now a hook 
right *before* _HashHTMLBlocks. Or -- as in this case -- you want to create a 
new block-level structure, in which case it should work recursively (e.g. a 
fenced codeblock that is part of a block quote). For this, there are now two 
hooks inside _RunBlockGamut.

Documentation at http://code.google.com/p/pagedown/wiki/PageDown has also been 
updated.

Original comment by b...@stackoverflow.com on 3 Feb 2013 at 9:52