Ticket #1134 (reopened defect)
section definition syntax should allow leading spaces
| Reported by: | EricShulman | Owned by: | MartinBudden |
|---|---|---|---|
| Priority: | major | Milestone: | 2.7.1 |
| Component: | core | Version: | |
| Severity: | low | Keywords: | |
| Cc: |
Description
Some authors, when defining tiddler sections (using the ! heading syntax), have used leading whitespace in the heading text, like this:
! sectionname
This whitespace is included solely for readability and does not appear when the heading is rendered in the DOM. However, it is still being treated as part of the sectionname. As a result, use of
<<tiddler SomeTiddler##sectionname>>
fails to retrieve the expected section content, and it is necessary to explicitly include the leading whitespace in the section reference, like this:
<<tiddler [[SomeTiddler## sectionname]]>>
In order to omit this space from the tiddler reference and allow flexible use of leading/trailing whitespace, the following regexp -- used in TiddlyWiki.prototype.getTiddlerText() to locate a section within a given tiddler's text -- should be changed from this:
var re = new RegExp("(^!{1,6}" + section.escapeRegExp() + "[ \t]*\n)","mg");
to this:
var re = new RegExp("(^!{1,6}[ \t]*" + section.escapeRegExp() + "[ \t]*\n)","mg");
Note that the current regexp already allows (and ignores) trailing whitespace. The proposed change simply permits leading whitespace to be processed (and ignored) in the same way.
