https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292010-08-04T21:04:59ZRedmineRedmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=189752010-08-04T21:04:59ZMarc Mengel
<ul></ul><p>Note that this is now in:<br /> lib/redmine/wiki_formatting.rb and not down in the textile specific code...</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=283022011-04-26T09:52:25ZMichael Kussmaul
<ul></ul><p>It seems in current trunk it is still not included? Is there anything wrong with the proposed regex?</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=283032011-04-26T10:31:20ZEtienne Massip
<ul><li><strong>Target version</strong> set to <i>Candidate for next minor release</i></li></ul><p>Looks ok, but why do the actual RE has such a limitation preventing a closing curly brace to be present in the argument list ?</p>
<p>(<a class="source" href="https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/lib/redmine/wiki_formatting.rb#L74">source:trunk/lib/redmine/wiki_formatting.rb#L74</a>)</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=283062011-04-26T11:41:02ZMichael Kussmaul
<ul></ul><p>I'm not sure, if this is the main "issue" - but there are quite some macro-plugins out there, which need support for multiline macros (e.g. <a class="external" href="http://www.redmine.org/boards/3/topics/10649">http://www.redmine.org/boards/3/topics/10649</a> or also the graphviz-plugin could benefit from it).</p>
<p>Currently they only work by patching multiple redmine files (if I understood the docu of those plugins correctly). They usually work all the same: an external tool generates an image. The "recipe" how to bake this image is inside a multi-line macro. I like this approach, as it allows to extend redmine in a very flexible way.</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=284122011-04-28T18:34:52ZEtienne Massip
<ul><li><strong>Category</strong> set to <i>Text formatting</i></li></ul> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=371422012-04-01T21:33:36ZThimios Dimopulos
<ul></ul><p>There is no MACROS_RE = line on Redmine 1.3. Has anyone managed to make the plugin work with redmine 1.3?</p>
<p>thanks!</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=373212012-04-10T11:04:08ZThimios Dimopulos
<ul></ul><p>An alternative to using this plugin, is using MathJax: <a class="external" href="https://github.com/process91/redmine_latex_mathjax">https://github.com/process91/redmine_latex_mathjax</a></p>
<p>Just installed it on Redmine 1.3 stable and it works fine.</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=378172012-05-02T05:47:01ZOscar Dekkers
<ul></ul><p>+1</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=389822012-06-13T16:01:52ZSimon Delamare
<ul></ul><p>In Redmine 1.3, MACROS_RE is defined in redmine/app/helpers/application_helper.rb</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=402592012-08-08T21:37:54ZEtienne Massip
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Resolved</i></li><li><strong>Target version</strong> changed from <i>Candidate for next minor release</i> to <i>2.1.0</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Looks like it has been fixed with <a class="changeset" title="Slight change to the macro regexp." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/10178">r10178</a>, could you please confirm?</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=402712012-08-09T14:19:42ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><p>Etienne Massip wrote:</p>
<blockquote>
<p>Looks like it has been fixed with <a class="changeset" title="Slight change to the macro regexp." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/10178">r10178</a>, could you please confirm?</p>
</blockquote>
<p>No, the regexp does not match multiple lines (no <code>m</code> modifier). The problem with passing a block of text to a macro is that it would be processed by all previous parsers (textile, redmine links...) and has a lot of chances to be altered. To make this feature work nicely, we should prevent that.</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=402782012-08-09T17:45:37ZEtienne Massip
<ul><li><strong>Target version</strong> changed from <i>2.1.0</i> to <i>Candidate for next major release</i></li></ul><p>Indeed, I missed the modifier (you committed the "allow curly braces as argument" part, still).</p>
<p>Wouldn't it make sense to parse macro tags first?</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=402792012-08-09T17:56:56ZEtienne Massip
<ul><li><strong>Status</strong> changed from <i>Resolved</i> to <i>New</i></li><li><strong>Resolution</strong> deleted (<del><i>Fixed</i></del>)</li></ul> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=403362012-08-13T14:07:41ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Target version</strong> changed from <i>Candidate for next major release</i> to <i>2.2.0</i></li></ul><p>Etienne Massip wrote:</p>
<blockquote>
<p>Wouldn't it make sense to parse macro tags first?</p>
</blockquote>
<p>Sure, but that's not that simple. Formatted text is cached and macro output must not be parsed by textile and redmine links. The solution would be to "catch" macro at the beginning then substitue with their output at the very end of the process.</p> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=403372012-08-13T14:08:25ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Subject</strong> changed from <i>Modify MACRO_RE to match over multiple lines and ignore single curly braces</i> to <i>Let macros optionally match over multiple lines and ignore single curly braces</i></li></ul> Redmine - Feature #3061: Let macros optionally match over multiple lines and ignore single curly braceshttps://www.redmine.org/issues/3061?journal_id=404142012-08-18T08:41:26ZJean-Philippe Langjp_lang@yahoo.fr
<ul><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li><li><strong>Assignee</strong> set to <i>Jean-Philippe Lang</i></li><li><strong>Target version</strong> changed from <i>2.2.0</i> to <i>2.1.0</i></li><li><strong>Resolution</strong> set to <i>Fixed</i></li></ul><p>Implemented in <a class="changeset" title="Macros processing overhaul (#3061, #11633). * macro arguments are no longer parsed by text forma..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/10209">r10209</a>, <a class="changeset" title="Let macros optionally accept a block of text (#3061)." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/10210">r10210</a>. Macros now optionally accept a block of text as a third argument. Examples from the doc:</p>
<pre><code class="ruby syntaxhl"><span class="no">Redmine</span><span class="o">::</span><span class="no">WikiFormatting</span><span class="o">::</span><span class="no">Macros</span><span class="p">.</span><span class="nf">register</span> <span class="k">do</span>
<span class="c1"># Declaring a macro that do not accept a block of text</span>
<span class="n">macro</span> <span class="ss">:my_macro</span> <span class="k">do</span> <span class="o">|</span><span class="n">obj</span><span class="p">,</span> <span class="n">args</span><span class="o">|</span>
<span class="s2">"My macro output"</span>
<span class="k">end</span>
<span class="c1"># Declaring a macro that accepts a block of text (as third argument)</span>
<span class="n">macro</span> <span class="ss">:my_macro2</span> <span class="k">do</span> <span class="o">|</span><span class="n">obj</span><span class="p">,</span> <span class="n">args</span><span class="p">,</span> <span class="n">text</span><span class="o">|</span>
<span class="s2">"My macro output"</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Macros are invoked in formatted text using the following</span>
<span class="c1"># syntax:</span>
<span class="c1">#</span>
<span class="c1"># No arguments:</span>
<span class="c1"># {{my_macro}}</span>
<span class="c1">#</span>
<span class="c1"># With arguments:</span>
<span class="c1"># {{my_macro(arg1, arg2)}}</span>
<span class="c1">#</span>
<span class="c1"># With a block of text:</span>
<span class="c1"># {{my_macro2</span>
<span class="c1"># multiple lines</span>
<span class="c1"># of text</span>
<span class="c1"># }}</span>
<span class="c1">#</span>
<span class="c1"># With arguments and a block of text</span>
<span class="c1"># {{my_macro2(arg1, arg2)</span>
<span class="c1"># multiple lines</span>
<span class="c1"># of text</span>
<span class="c1"># }}</span>
<span class="c1">#</span>
<span class="c1"># Note that the closing tag }} must be at the start of a new line</span>
</code></pre>
<p>With <a class="changeset" title="Macros processing overhaul (#3061, #11633). * macro arguments are no longer parsed by text forma..." href="https://www.redmine.org/projects/redmine/repository/svn/revisions/10209">r10209</a>, the output of macros is automatically escaped. Use <code>#html_safe</code> if the generated output contains html tags that should not be escaped. Examples:</p>
<pre><code class="ruby syntaxhl"><span class="no">Redmine</span><span class="o">::</span><span class="no">WikiFormatting</span><span class="o">::</span><span class="no">Macros</span><span class="p">.</span><span class="nf">register</span> <span class="k">do</span>
<span class="n">macro</span> <span class="ss">:my_macro</span> <span class="k">do</span> <span class="o">|</span><span class="n">obj</span><span class="p">,</span> <span class="n">args</span><span class="o">|</span>
<span class="s2">"Unsafe <tag>"</span>
<span class="k">end</span>
<span class="n">macro</span> <span class="ss">:my_macro2</span> <span class="k">do</span> <span class="o">|</span><span class="n">obj</span><span class="p">,</span> <span class="n">args</span><span class="o">|</span>
<span class="s2">"Safe <tag>"</span><span class="p">.</span><span class="nf">html_safe</span>
<span class="k">end</span>
<span class="k">end</span>
<span class="c1"># Then:</span>
<span class="c1">#</span>
<span class="c1"># {{my_macro}}</span>
<span class="c1"># produces: Unsafe &lt;tag&gt;</span>
<span class="c1">#</span>
<span class="c1"># {{my_macro2}}</span>
<span class="c1"># produces: Safe <tag></span>
</code></pre>