https://www.redmine.org/https://www.redmine.org/favicon.ico?16793021292008-07-25T03:19:01ZRedmineRedmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=40732008-07-25T03:19:01ZCalvin Cheng
<ul></ul><p>Youssef Abou-Kewik wrote:</p>
<blockquote>
<p>We're going to be using Redmine internally with lots of Python code involved. Thought I'd share this patch with you guys. <br />I never wrote in ruby before, and I used some of the code mentioned here: <a class="external" href="http://matt.tarbit.org/2008/02/05/extending-bluecloth-with-pygments">http://matt.tarbit.org/2008/02/05/extending-bluecloth-with-pygments</a></p>
<p>You need to test that pygmentize works on your system first, and if it does, this should work just fine. Unfortunately, syntax highlighting is not a plugin.</p>
</blockquote>
<p>Looks good. It's what I have been looking for!</p>
<p>Coderay has simply been just too limited. Pygments rock in comparison.</p>
<p>Will give this patch a shot. But it looks like I have to maintain this file thereafter since I track the trunk directly.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=40762008-07-25T20:17:09ZYoussef Abou-Kewik
<ul><li><strong>File</strong> <a href="/attachments/805">scm_patch_pygmentize.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/805/scm_patch_pygmentize.diff">scm_patch_pygmentize.diff</a> added</li></ul><p>I'm attaching another update. This one should count fully on pygmentize instead of CodeRay (the previous patch relied on CodeRay to determine file type). However, this one relies on writing a temp file to /tmp where pygmentize can read it and determine its file type on its own. Also, files with UTF8 encoding should work now.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=48532008-09-19T14:52:07ZAnatolii Kucheruck
<ul><li><strong>File</strong> <a href="/attachments/960">scm_patch_pygmentize2.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/960/scm_patch_pygmentize2.diff">scm_patch_pygmentize2.diff</a> added</li></ul><p>Youssef Abou-Kewik wrote:</p>
<blockquote>
<p>I'm attaching another update. This one should count fully on pygmentize instead of CodeRay (the previous patch relied on CodeRay to determine file type). However, this one relies on writing a temp file to /tmp where pygmentize can read it and determine its file type on its own. Also, files with UTF8 encoding should work now.</p>
</blockquote>
<p>There are one "bug" in this patch: if pygmentize can't recognize file type (e.g. file has no extension or pygmentize has no such type in lexer's list), the error was occurred and empty string was returned, and we have no content. <br />I'm attaching athother one path with fix this (file type compulsorily set to "text" in described case).</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=64492009-01-04T16:47:13ZKornelius Kalnbach
<ul></ul><p>It is true that CodeRay's language support is still very limited, but development has started again. We're <a href="http://redmine.rubychan.de/projects/show/coderay" class="external">using</a> Redmine for issue tracking :)</p>
<p>The <a href="https://rubyforge.org/frs/?group_id=704&release_id=30086" class="external">latest</a> CodeRay version supports some additional languages, but Python is still not included. Python support for CodeRay is scheduled for the next version.</p>
<p>pygments is a very good tool, I can only recommend it - but it would be nice to have a pure-Ruby solution. Ultraviolet is one with a lot of languages, but it has more dependecies and is slower than CodeRay.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=64502009-01-04T16:49:30ZJean-Philippe Langjp_lang@yahoo.fr
<ul></ul><blockquote>
<p>We're using Redmine for issue tracking :)</p>
</blockquote>
<p>Excellent news :)</p>
<blockquote>
<p>The latest CodeRay version supports some additional languages</p>
</blockquote>
<p>I'll upgrade as soon as possible to this new release. Thanks!</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=69092009-01-26T00:31:05ZEric Davis
<ul></ul><p>Thank you for the patch. There are a few improvements needed though:</p>
<ol>
<li>Requires a UNIX environment. From what I non POSIX systems (Windows) don't support output redirection (e.g. The <code>></code> in `echo #{escape_shell_arg(content)} > /tmp/#{basename}`)</li>
<li>Requires several shell commands (<code>pygmentize</code>, <code>echo</code>, <code>rm</code>)</li>
<li>Shell commands are assumed to be located in the system PATH, which may fail under environments like Apache Passenger</li>
<li>Files are written and deleted without testing if they exist and are valid first. It wouldn't be too difficult to trick the regex in <code>escape_shell_arg</code> to remove a system file</li>
<li>Sending commands to the shell (<code>`command`</code>) are run asynciolsly. The <code>system(command)</code> should be used instead.</li>
</ol> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=69202009-01-26T10:25:51ZYoussef Abou-Kewik
<ul></ul><p>Well, the patch was for an immediate need that we had at our office. However, I think something like<br /><a class="external" href="http://code.google.com/p/syntaxhighlighter/">http://code.google.com/p/syntaxhighlighter/</a></p>
<p>or <br /><a class="external" href="http://shjs.sourceforge.net/">http://shjs.sourceforge.net/</a></p>
<p>Are actually better solutions than CodeRay or even my patch. I'll try to work something out using one of the solutions above and update this patch when I get some time.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=69632009-01-28T15:49:54ZKornelius Kalnbach
<ul></ul><p>The question is: does it highlight Ruby as good as the current highlighter? Most syntax highlighters have very bad Ruby support. That was the original reason for me to write CodeRay.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=69682009-01-28T18:35:59ZKornelius Kalnbach
<ul></ul><p>CodeRay development is slow at the moment. Maybe it would be best to make syntax highlighting a plugin (as the original post suggested), and leave the decision to the users. Ultraviolet for example supports a lot more languages and themes, but requires Oniguruma and other libraries, while solutions like JavaScript syntax highlighting minimize server load (I'm guessing here). But RedMine would still need a default syntax highlighter.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=69742009-01-28T21:33:08ZCasseen Star
<ul></ul><p>I found another patch to use pygments inside redmine: <a class="external" href="http://jakewharton.com/2008/11/12/using-pygments-in-redmine/">http://jakewharton.com/2008/11/12/using-pygments-in-redmine/</a></p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=70752009-02-02T23:04:02ZEric Davis
<ul></ul><p>Kornelius Kalnbach wrote:</p>
<blockquote>
<p>CodeRay development is slow at the moment. Maybe it would be best to make syntax highlighting a plugin (as the original post suggested), and leave the decision to the users.</p>
</blockquote>
<p>I like that idea. Then alternative highlighers can be used and worked on separately.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=81892009-03-22T23:45:25ZHolger Just
<ul><li><strong>File</strong> <a href="/attachments/1729">scm_patch_pygmentize3.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1729/scm_patch_pygmentize3.diff">scm_patch_pygmentize3.diff</a> added</li></ul><p>While the solution of Jake Wharton (see note #10) seems to be the cleanest version of the naive implementation, at least the current stable version of Debian does not include the required pygments patch. Therefore we still need a temporary file with the correct file extension to pass to the <code>pygmentize</code> program.</p>
<p>Because of the outstanding issues on the provided patch, I tried to improve it. My current version addresses some of the issues of Eric (#6). I now use the tempfile package (which needed to be extended for Ruby < 1.9 however). This should resolve most issues with unsafe file access. Some operations with weird filenames are still going to fail. But I think, those filenames should still be safe as tempfile is going to refuse to create certain dangerously named files.</p>
<p>Only <code>pygmentize</code> is required to be in the current path. The current version shipped with Debian Lenny (in package python-pygments) works fine. The patch however will probably still not work on Windows as the rewriting of the error stream of <code>pygmentize</code> will fail on that platform. However, this was not tested.</p>
<p><strong>Note:</strong> Previous version of the patch perform unsafe file operations. Using specially crafted filenames in the repository it was possible to read, write and delete <strong>any</strong> file accessible by the user of the webserver. If you use one of the previously provided patches, you should update your installation as soon as possible!</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=85612009-04-08T14:37:46ZSebastien Metrot
<ul><li><strong>File</strong> <a href="/attachments/1841">redmine_pygmentize_wiki.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/1841/redmine_pygmentize_wiki.diff">redmine_pygmentize_wiki.diff</a> added</li></ul><p>hi,</p>
<p>I tried the different patches to include Pygment sntax hilighting in redmine but none of them seemed to support it in the wiki. I hacked it a bit and came up with a solution that seems to work. I have attached my patch against revision 2666 of the redmine svn.</p>
<p>It was my first time hacking ruby and the solution seems very dirty to me (particularly the & that I have to transform into & by hand... anyone knows a better solution to unescape the wiki code?).</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=85622009-04-08T15:57:52ZJean-Baptiste Barth
<ul></ul><p>The ampersands becoming "%x%x" is a redcloth bug ; you could have a look at my second patch in <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Make syntax highlighting pluggable (Closed)" href="https://www.redmine.org/issues/2985">#2985</a>, it solves this problem by simply desactivating it in redcloth (be careful, there are other redcloth changes in this patch). I haven't took a deeper look at it to see why redcloth do that, and how to solve it properly sorry...</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=92402009-05-14T09:24:58ZYoussef Abou-Kewik
<ul><li><strong>File</strong> <a href="/attachments/2024">syntax_highlight.diff</a> <a class="icon-only icon-download" title="Download" href="/attachments/download/2024/syntax_highlight.diff">syntax_highlight.diff</a> added</li></ul><p>OK, so this patch removes the dependency on pygmentize and no longer writes any temp files. We now use javascript highlighter which takes the load to the client side.</p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=98522009-06-22T05:44:18ZJiongliang Zhang
<ul></ul><p>There is a new way using pygments as highlight tool for repository files: <a class="external" href="http://www.redmine.org/boards/3/topics/6890">http://www.redmine.org/boards/3/topics/6890</a></p> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=752642016-12-24T05:05:02ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/3032">Feature #3032</a>: Use google Prettify for syntax highlighting instead of CodeRay</i> added</li></ul> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=753522016-12-26T01:18:38ZGo MAEDA
<ul><li><strong>Related to</strong> <i><a class="issue tracker-2 status-5 priority-4 priority-default closed" href="/issues/24681">Feature #24681</a>: Syntax highlighter: replace CodeRay with Rouge</i> added</li></ul> Redmine - Patch #1651: Hack to make redmine use pygmentize instead of CodeRayhttps://www.redmine.org/issues/1651?journal_id=876632018-09-29T08:28:17ZGo MAEDA
<ul><li><strong>Category</strong> set to <i>Text formatting</i></li><li><strong>Status</strong> changed from <i>New</i> to <i>Closed</i></li></ul><p>In the upcoming Redmine 4.0, such a hack is no longer necessary because the new syntax highlighter supports a large number of programming languages. Please see <a class="issue tracker-2 status-5 priority-4 priority-default closed" title="Feature: Syntax highlighter: replace CodeRay with Rouge (Closed)" href="https://www.redmine.org/issues/24681">#24681</a> for details.</p>