cebe / markdown

A super fast, highly extensible markdown parser for PHP

Home Page:http://markdown.cebe.cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Splitting markup into several files / cross-linking problem

olegkrivtsov opened this issue · comments

I need to split blocks by chapters, so each chapter will be rendered to a separate HTML file. I can do this with the current version of your code (by overriding parse() method and enumerating top-level absy blocks), but the problem is with cross-linking elements.

A [cross-link](#element-id) may link to any element with "id" attribute. To correctly render links, I have to determine in what HTML file what element is located. To determine in which chapter which element will go, I would have to somehow enumerate all blocks (not only top-level ones), but this is difficult to do inside of parse() method (because each block type has each own structure). It would be much easier to do that inside of parseBlocks() method, if you made the changes I requested previously.

Can you help?

This is closely related to #113.

Hi @cebe is there any progress on this? Can you just make these two changes:

  • make Parser::prepareMarkers() method protected
  • and make Parser::_depth property protected

These small changes will not break your API and will allow me to use your library without tweaking.

hi @olegkrivtsov, is this still relevant? having separate HTML files a reference should probably include the file name to be able to link correctly.