argument))
-footnoteGrob =
-#(define-music-function (parser location grob-name offset text footnote)
- (symbol? number-pair? markup? markup?)
- (_i "Attach @var{text} to @var{grob-name} at offset @var{offset},
-with @var{text} referring to @var{footnote} (use like @code{\\once})")
- (make-music 'FootnoteEvent
- 'automatically-numbered #f
- 'symbol grob-name
- 'X-offset (car offset)
- 'Y-offset (cdr offset)
- 'text text
- 'footnote-text footnote))
-
-autoFootnoteGrob =
-#(define-music-function (parser location grob-name offset footnote)
- (symbol? number-pair? markup?)
- (_i "Footnote @var{grob-name} with the text in @var{footnote}
-allowing for the footnote to be automatically numbered such that
-the number appears at @var{offset}. Note that, for this to take effect,
-auto-numbering must be turned on in the paper block. Otherwise, no
-number will appear. Use like @code{\\once})")
- (make-music 'FootnoteEvent
- 'automatically-numbered #t
- 'symbol grob-name
- 'X-offset (car offset)
- 'Y-offset (cdr offset)
- 'text (make-null-markup)
- 'footnote-text footnote))
-
-
footnote =
-#(define-music-function (parser location offset text footnote)
- (number-pair? markup? markup?)
- (_i "Attach @var{text} at @var{offset} with @var{text} referring
-to @var{footnote} (use like @code{\\tweak})")
- (make-music 'FootnoteEvent
- 'automatically-numbered #f
- 'X-offset (car offset)
- 'Y-offset (cdr offset)
- 'text text
- 'footnote-text footnote))
-
-autoFootnote =
-#(define-music-function (parser location offset footnote)
- (number-pair? markup?)
- (_i "Footnote the item after which this comes with the text in
-@var{footnote} allowing for the footnote to be automatically numbered
-such that the number appears at @var{offset}. Note that, for this to
-take effect, auto-numbering must be turned on in the paper block.
-Otherwise, no number will appear. Use like @code{\\tweak})")
- (make-music 'FootnoteEvent
- 'automatically-numbered #t
- 'X-offset (car offset)
- 'Y-offset (cdr offset)
- 'text (make-null-markup)
- 'footnote-text footnote))
+#(define-music-function (parser location text offset grob-name footnote)
+ ((markup?) number-pair? (symbol? '()) markup?)
+ (_i "Attach @var{text} at @var{offset} with @var{text} referring to
+@var{footnote}. If @var{text} is given as @code{\\default}, use
+autonumbering instead. Note that, for this to take effect,
+auto-numbering must be turned on in the paper block. Otherwise, no
+number will appear. Footnotes are applied like articulations. If a
+symbol @var{grob-name} is specified, all grobs of that kind at the
+current time step are affected.")
+ (make-music
+ 'FootnoteEvent
+ 'X-offset (car offset)
+ 'Y-offset (cdr offset)
+ 'automatically-numbered (not text)
+ 'text (or text (make-null-markup))
+ 'footnote-text footnote
+ 'symbol grob-name))
grace =
#(def-grace-function startGraceMusic stopGraceMusic
r"\1\\accidentalStyle", str)
return str
+def brace_matcher (n):
+ # poor man's matched brace scanning, gives up
+ # after n+1 levels. Matches any string with balanced
+ # braces inside; add the outer braces yourself if needed.
+ # Nongreedy.
+ return r"[^{}]*?(?:{"*n+r"[^{}]*?"+r"}[^{}]*?)*?"*n
+
+matchstring = r'"(?:[^"\\]|\\.)*"'
+matcharg = (r"\s+(?:[$#]['`]?\s*(?:[a-zA-Z]\S*|" + matchstring + r"|\("
+ + paren_matcher(20) + r"\))|" + matchstring + r"|\\[a-z_A-Z]+)")
+matchmarkup = (r'(?:\\markup\s*(?:{' + brace_matcher (20) +r'}|' +
+ matchstring + r'|(?:\\[a-z_A-Z][a-z_A-Z-]*(?:' + matcharg +
+ r')*?\s*)*(?:' + matchstring + "|{" + brace_matcher (20) +
+ "}))|" + matchstring + ")")
+
+@rule((2, 15, 25), r"\(auto)?Footnote(Grob)? -> \footnote")
+def conv (str):
+ # The following replacement includes the final markup argument in
+ # the match in order to better avoid touching the equally named
+ # markup function. The other functions have unique names, so
+ # there is no point in including their last, possibly complex
+ # argument in the match.
+ str = re.sub (r"\\footnote(" + matcharg + (r")(\s*" + matchmarkup)*2 + ")",
+ r"\\footnote\2\1\3", str)
+ str = re.sub (r"\\footnoteGrob"+("(" + matcharg + ")")*2 + r"(\s*" + matchmarkup + ")",
+ r"\\footnote\3\2\1", str)
+ str = re.sub (r"\\autoFootnoteGrob" + ("(" + matcharg + ")")*2,
+ r"\\footnote\2\1", str)
+ str = re.sub (r"\\autoFootnote",
+ r"\\footnote", str)
+ return str
# Guidelines to write rules (please keep this at the end of this file)
#
# - keep at most one rule per version; if several conversions should be done,