4 ms·
> The internals of the app uses NSRegularExpression I tried to implement my version of this idea[1] with regular expressions too, using OgreKit. I ran into all
by bodhi 15y ago
> The internals of the app uses NSRegularExpression
I tried to implement my version of this idea[1] with regular expressions too, using OgreKit. I ran into all sorts of problems with corner cases, especially with nesting of block-level elements (lists/blockquotes/code). I wanted to switch over to a parser-based implementation, but at the time all the existing parsers were setup to emit HTML, so getting character-offsets out of the parser wasn't possible without hacking the parser to death.
There's been some good discussion on the Markdown list[2] recently about these sorts of things, a really interesting example is PEG Markdown Highlight[3], which is exactly what I wanted to do with my app, but I was too busy (read: lazy) to get around to.
[1]: http://keshiki.net/markdown-editor/ http://keshiki.net/markdown-editor/
[2]: http://six.pairlist.net/mailman/listinfo/markdown-discuss http://six.pairlist.net/mailman/listinfo/markdown-discuss
[3]: Project: http://hasseg.org/peg-markdown-highlight/ http://hasseg.org/peg-markdown-highlight/ Discussion: http://six.pairlist.net/pipermail/markdown-discuss/2011-June/002129.html http://six.pairlist.net/pipermail/markdown-discuss/2011-June...
- xentronium 15y ago> I wanted to switch over to a parser-based implementation, but at the time all the existing parsers were setup to emit HTML, so getting character-offsets out of the parser wasn't possible without hacking the parser to death. You might want to try libupskirt [1], library github uses. [1] http://fossil.instinctive.eu/libupskirt/index http://fossil.instinctive.eu/libupskirt/index
- bodhi 15y agoCool, thanks. I haven't looked deeply into it, but from a quick glance it seems to want to transform the input. For my use case I need a parse tree, with specific byte (well, character really) offsets. For example, I need to know where the link started, not that there is now a a link with text T and href H. My program (and Macchiato I assume) doesn't actually transform the source to an output format, we add attributes to the source text (similar to RTF).