Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Editsection plugin: Relax path regex (fixing NoReverseMatch) (#1299)
* Rework editsection plugin (fixes #1246) The main problem of editsection is to find the correct location of the section to edit in the source. Previously, that was done with custom, regex-based parsing, but that fails when code blocks contain lines which look like a header (for example, python comments). This patch uses another approach to find the correct sections. It uses extended versions of the BlockParsers responsible for creating headers, which annotate those headers with the consumed source block. Since we know now which input was responsible for generating the header, we can easily locate it in the markdown source. * try to make the linter happy... * try harder to make the linter happy... * try even harder to make the linter happy... * add a test for nonunique headers * reformat tests, too * reorder imports * Pass current revision to Editor.get_widget()/get_admin_widget() Sometimes it is useful to have the current revision in the editor widget instance, for example to create preview and upload links, autocomplete, ... <textarea name="content" data-upload-url='/wiki/my-page/_plugin/attachments/...'> Previously, EditorBase had an instance attribute "instance", but that doesn't make sense (there is only one global instance of Editor) and wasn't ever filled anyway. This patch removes that, renames the "instance" parameter in get_widget()/get_admin_widget() to "revision" (to make clear what this parameter is) and fills it appropriately. * add tests to improve coverage * Relax editsection path regex Problem: The following, valid markdown will throw a NoReverseMatch exception: # Title1 {#some_id_with.dot} This is due to editsection's url regex not allowing dots and other, non-whitespace characters. Solution: Relax the url regex to allow any non-whitespace character, as HTML5 does. * fix linting
- Loading branch information