Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move codespan detection from md_analyze_backtick() into...
md_is_code_span(), called from md_collect_marks(). We have to do this at the same time as detecting raw inline HTML to follow CommonMark priority requirements. Also it is done very differently now: When scanning for the closer mark, we remember (the latest) position of potential closers for all other lengths as well. This means that: (1) If we find it, we reduced the task because all subsequent scan shall begin after the closer. (2) If we do not find it, then we have to reach the end of the block and hence we then know (for every allowed marker length) the position of last such backtick sequence. (3) That makes the guaranty that any subsequent call with either succeed in its scan (and reduce the task even further); or that we shall be able to detect instantly there is no suitable closer. I.e. every call either reduces the task by O(n) scan (1); or collects all the data in O(n) because (2) happens at most once; or fails in O(1) (3). This makes O(n) guaranty of the function complexity. Fixes #59.
- Loading branch information
Showing
2 changed files
with
118 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters