Optimise content parsing hook
davestewart opened this issue · comments
Background
Right now, the module hooks into Content's content:file:afterParse
hook to process image paths.
The callback hook receives the the markdown AST which – depending on the content – can be quite large.
For example, transformed code can generate many, many spans, so in order to exclude code
and potentially other invalid elements, but include custom components we use a tags
lookup to determine whether to walk a visited element.
There is possibly the potential to optimise this:
- using a remark plugin to replace images before code conversion has begin
- hooking into
content:file:beforeParse
and using much simpler parsing / regular expressions to match and replace potential paths
Proposal
Spike the regexp route and see if it's simple / reliable, then look into seeing how the remark plugin approach might work.