Posting HTML code to the issues.

Get help from other users here.

Moderators: Developer, Contributor

Vox
Posts: 2
Joined: 09 Jul 2009, 09:18

Posting HTML code to the issues.

Post by Vox »

Hi! We are using Mantis version 1.1.6 and really apprecaite it.

One question: our webmaster often needs to post HTML code samples into the issues. These may include any tags like div, span, a, table, td, tr, b, i, u etc - often including URLs and tag attributes. The problem is - some parts of the HTML code in mantis issues is rendered as HTML, some not. What we want is to have a possibility of deactivating any HTML interpretation in mantis. Which means - we need html source code as a plain text (as if you open html file in notepad). A primitive example - if a reporter posts <b>http://www.foobar.org</b>, then it should be displayed as a source code, and not as a http://www.foobar.org. Is there a way to do it?

Many thanks in advance!
Alex
deboutv
Posts: 507
Joined: 15 Jan 2007, 14:31
Location: La Ciotat, FRANCE
Contact:

Re: Posting HTML code to the issues.

Post by deboutv »

You have to configure Mantis (put this in your config_inc.php and set it according to your needs):

Code: Select all

	############################
	# Mantis HTML Settings
	############################

	# --- html tags -------------------

	# Set this flag to automatically convert www URLs and
	# email adresses into clickable links
	$g_html_make_links		= ON;

	# These are the valid html tags for multi-line fields (e.g. description)
	# do NOT include href or img tags here
	# do NOT include tags that have parameters (eg. <font face="arial">)
	$g_html_valid_tags		= 'p, li, ul, ol, br, pre, i, b, u, em';

	# These are the valid html tags for single line fields (e.g. issue summary).
	# do NOT include href or img tags here
	# do NOT include tags that have parameters (eg. <font face="arial">)
	$g_html_valid_tags_single_line		= 'i, b, u, em';
Want more plugins to customize Mantis?
=> http://deboutv.free.fr/mantis/

Mantis: 1.1.0, 1.1.0a2
PHP: 5.0.4
SQL: MySQL 5.0.19
OS: Linux
Vox
Posts: 2
Joined: 09 Jul 2009, 09:18

Re: Posting HTML code to the issues.

Post by Vox »

Thanks! But this would mean - we need to deactivate all tags. Better would be to mark some blocks as "code" to disable html parsing there. For example, DokuWiki (which we also use) has such a feature - http://www.dokuwiki.org/syntax#non-parsed_blocks Is there any similar trick in Mantis? Thanks!
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

Vox wrote:Thanks! But this would mean - we need to deactivate all tags. Better would be to mark some blocks as "code" to disable html parsing there. For example, DokuWiki (which we also use) has such a feature - http://www.dokuwiki.org/syntax#non-parsed_blocks Is there any similar trick in Mantis? Thanks!
You can use mantisbt ver of 1.2.x with Highlight plugin.
Crayon
Posts: 6
Joined: 29 Jul 2009, 16:21
Location: Somewhere in North America

Re: Posting HTML code to the issues.

Post by Crayon »

Kirill wrote:You can use mantisbt ver of 1.2.x with Highlight plugin.
I tried your idea, but it seems it's not working. Try this code:

Code: Select all

<pre><code>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul> 
</code></pre>
I see a white rectangle, the place where the should be, and after that it's the list with bullets.
Crayon
Posts: 6
Joined: 29 Jul 2009, 16:21
Location: Somewhere in North America

Re: Posting HTML code to the issues.

Post by Crayon »

Maybe I'm doing something wrong in my code.

BTW, thanks for the plugin :)
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

Crayon wrote:Maybe I'm doing something wrong in my code.

BTW, thanks for the plugin :)
Thank you for bug. If you can, test last version from git.
Crayon
Posts: 6
Joined: 29 Jul 2009, 16:21
Location: Somewhere in North America

Re: Posting HTML code to the issues.

Post by Crayon »

Thanks, for the quick reply. The code is now highlighted correctly, but I'm having problems with multi-line text with carriage return.

In MantisBT Formatting, when Text Processing is ON I get this:
Image

When it's OFF I get this:
Image

The code for the description is:

Code: Select all

<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>

<pre>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
</pre>

<pre><code>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
</code></pre>
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

Thanks for bug. Try 0.4.5 version from git :wink:
Crayon
Posts: 6
Joined: 29 Jul 2009, 16:21
Location: Somewhere in North America

Re: Posting HTML code to the issues.

Post by Crayon »

Cool it's working now, but I have another problem ;)

URL are not processed, for example in my description I see this (instead of a link):

Code: Select all

<a href="/mantis/view.php?id=3" title="[feedback] this is for a test">0000003</a>
BTW: do you have an issue tracker for the Highlight plugin? Or It's best if I continue posting things here?

Thanks
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

Yes. I have bugtracker. http://bug.kraeg.ru/
jurgenhaas
Posts: 3
Joined: 05 Feb 2010, 12:50

Re: Posting HTML code to the issues.

Post by jurgenhaas »

Hi Kirill, found your plugin today and I'm very excited about it. Just on thing doesn't work:

When I'm using <pre><code> ... something ... </code></pre> then the code inside is rendered very nicely. But when I simply use <b>bold</b> text, then the word bold isn't formatted bold as expected but the tags <b> and </b> are visible as text.

When I turn off highlight then the text is bold, but ofcourse syntax highlighting doesn't work anymore.

Any ideas on how I could get both to work simultaniously?
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

Yes, I see that. For now I work for fix it and rebuild main module of plugin.
thehandyman33
Posts: 6
Joined: 23 Sep 2010, 03:39

Re: Posting HTML code to the issues.

Post by thehandyman33 »

I couldn't find 'dummy-friendly' instructions for how to install this plugin, so here they are:

INSTALLATION:
- Browse to http://git.mantisforge.org/w/highlightcode.git
- Click the "snapshot" link next to the version you want (if you're not sure, get the most recent one, at the top of the list, labeled "Master")
- Download and extract the tar.gz file
- Inside the "highlightcode" directory, you'll find the "Highlight" (note the case)
- Upload the "Highlight" directory into the /plugins/ directory in your Mantis install. You should then have a /plugins/Highlight directory.
- Log into your Mantis install, browse to /manage_plugin_page.php
- Under "Available Plugins" (at the bottom), you will see "MantisBT KK Highlight 0.4.6" (version number may vary)
- Click the "Install" link on the right

(These steps worked for me, if anyone has corrections or additions please let me know and I will update the instructions). These are for Mantis 1.2. It would be nice if these instructions were included with the release.

USAGE:
Once you follow the instructions above, usage is hopefully straightforward. Simply surround the code you want highlighted with <pre><code></code></pre>. They have to be in that order. Below are some examples:

Code: Select all

<pre><code>
<b>This is HTML code!</b>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
</code></pre>

<pre><code>
<?php
echo 'This is PHP code?';
?>
</code></pre>

<pre><code>
/* This is CSS code */
.highlight {
text-align: right;
}
</code></pre>
-------

So this seems to work well enough... but there are a few issues. Please, if anyone has experience with this plugin and knows of fixes (or alternatives), let me know!

- code highlighting is monochrome... no coloring of any kind (as is common with other highlighters I've used). Comments are grayed out, functions and tags are bold, and regular text is, well, regular text. This is definitely better than nothing, but not by much.
- requires HTML tags to work... and they have to be in the right order, etc. <pre><code> is fine, but what if you want to use these tags in the highlighting? This doesn't work at all:

Code: Select all

<pre><code>
<pre><code>
This code should be highlighted, but it's not!
</code></pre>
</code></pre>
- I think that something like BB Code would work MUCH better, unfortunately I haven't been able to find a plugin or alternate solution for code highlighting in Mantis. The best mention I could find is http://www.mantisbt.org/bugs/view.php?id=3491 but this bug is currently marked "acknowledged"

---
UPDATE:
The same developer as the one that posted the code highlighting also posted a BBCode parser plugin here: http://git.mantisforge.org/w/bbcode.git

Unfortunately it only supports a small subset of BBCode, and most notably, does not support the "code" tag, so not much use in this case!

Code: Select all

Supported bbcode:
[b]		=> <strong>
[i]		=> <i>
[u]		=> <u>
[del]	=> <s>
[sub]	=> <sub>
[sup]	=> <sup>
[tt]	=> <tt>
[img]	=> <img>
[url]	=> <a href>
[left]	=> <div align>
[right]	=> <div align>
[center]=> <center>
[hr]	=> <hr>
[color]	=> <span style>
Hopefully these can be combined somehow.
Kirill
Posts: 640
Joined: 25 Nov 2007, 08:05
Location: Kaliningrad, RF
Contact:

Re: Posting HTML code to the issues.

Post by Kirill »

thehandyman33
If you want help write this plugin, I can add access to work with it.
Post Reply