• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Suggestion: [code] tag

Blah

Free supporter
1,924
Posts
11
Years
I find the code tag a little hard to post actual code inside. I think it ought to have a 100 character length as most programming styles expect, and remove the vertical scrollbar.

Most of the time, when I need to post code in the ROM hacking section I'm always utilizing the quote + spoiler tag instead because of the fixed ranges on the code tag. In some extreme cases like my last tutorial, I opted to use images taken from my text editor instead for syntax highlighting and readability, and those posts will become obsolete when the image dies.

Ideally, I would love the ability to parse Markdown and have that replace the code tag altogether <3
 
Last edited:

Touched

Resident ASMAGICIAN
625
Posts
9
Years
  • Age 122
  • Seen Feb 1, 2018
Yes, and no - the embed code for Github's gists would have to have a sanity check and would also have to be sanitized first, since this is all that is required to embed a gist:

Code:
<script src="https://gist.github.com/Incineroar/df3586ca04f750c7562e.js"></script>
this is for an old arduino sketch of mine, but basically it's the gist's url with .js appended to the end of it

Anyone could put an arbitrary script in the bbcode editor and it could lead to compromised user data. A sanity check would have to be added should anyone decide to add this ability.

And the YouTube embed uses an iframe. I don't think it's a problem to only allow people to specify your username and gist hash, much like you only need the YouTube video ID to embed a video using the BB code.
 
10,673
Posts
15
Years
  • Age 30
  • Seen Dec 30, 2023
I agree that a proper code tag would be beneficial in many cases. Until one is implemented; the best alternative is the "PHP" tag. This tag manages to highlight syntax at least somewhat successfully.

PHP
PHP:
<?php 
$x = 75; 
$y = 25;
 
function addition() { 
    $GLOBALS['z'] = $GLOBALS['x'] + $GLOBALS['y']; 
}
 
addition(); 
echo $z; 
?>

C#
PHP:
<#@ output extension=".txt" #>  
<#@ assembly name="System.Xml" #>  
<#  
 System.Xml.XmlDocument configurationData = ...; // Read a data file here.  
#>  
namespace Fabrikam.<#= configurationData.SelectSingleNode("jobName").Value #>  
{  
  ... // More code here.   
}

Java
PHP:
//import
import java.awt.Color;


public class FilterExample
{
	/*
	 *pre: image != null, image.length > 1, image[0].length > 1
	 *	image is a rectangular matrix, neighberhoodSize > 0
	 *post: return a smoothed version of image
	 */
	public Color[][] smooth(Color[][] image, int neighberhoodSize)
	{	//check precondition
		assert image != null && image.length > 1 && image[0].length > 1
				&& ( neighberhoodSize > 0 ) && rectangularMatrix( image )
				: "Violation of precondition: smooth";

		Color[][] result = new Color[image.length][image[0].length];

		for(int row = 0; row < image.length; row++)
		{	for(int col = 0; col < image[0].length; col++)
			{	result[row][col] = aveOfNeighbors(image, row, col, neighberhoodSize);
			}
		}

		return result;
	}


	// helper method that determines the average color of a neighberhood
	// around a particular cell.
	private Color aveOfNeighbors(Color[][] image, int row, int col, int neighberhoodSize)
	{	int numNeighbors = 0;
		int red = 0;
		int green = 0;
		int blue = 0;

		for(int r = row - neighberhoodSize; r <= row + neighberhoodSize; r++)
		{	for(int c = col - neighberhoodSize; c <= col + neighberhoodSize; c++)
			{	if( inBounds( image, r, c ) )
				{	numNeighbors++;
					red += image[r][c].getRed();
					green += image[r][c].getGreen();
					blue += image[r][c].getBlue();
				}
			}
		}

		assert numNeighbors > 0;
		return new Color( red / numNeighbors, green / numNeighbors, blue / numNeighbors );
	}

	//helper method to determine if given coordinates are in bounds
	private boolean inBounds(Color[][] image, int row, int col)
	{	return (row >= 0) && (row <= image.length) && (col >= 0)
				&& (col < image[0].length);
	}

	//private method to ensure mat is rectangular
	private boolean rectangularMatrix( Color[][] mat )
	{	boolean isRectangular = true;
		int row = 1;
		final int COLUMNS = mat[0].length;

		while( isRectangular && row < mat.length )
		{	isRectangular = ( mat[row].length == COLUMNS );
			row++;
		}

		return isRectangular;
	}
}
 

Lucario

Hardly active since 2017!
809
Posts
8
Years
the ability to embed gists would be great, I agree the
Code:
 tag at the moment isn't very usable.
 

Zeffy

g'day
6,402
Posts
15
Years
  • Age 27
  • Seen Feb 7, 2024
I never liked using the
Code:
 tag since... it does not achieve any sort of syntax highlighting that I hoped it would. The alternative mentioned by Gav above is the closest to what I expected the [code] tag to produce, but it's rather confusing to use the [php] tag to display non-PHP code. It would be great if the [code] tag accepted some sort of input to highlight its contents, such as [code="c++"] or something similar.

Being able to parse markdown would be a great feature, I think! Markdown syntax is significantly simpler compared to BBCode, though I think the main problem would be looking for a markdown parser that would support whatever platform PC runs on nowadays. Another problem would be the whether it's actually worth all that effort since markdown essentially produces similar outputs to the BBcode-styled posts, albeit with comparatively little effort.
 

Blah

Free supporter
1,924
Posts
11
Years
Hey it's been a while since this was addressed. I wonder if there are any updates/rejections regarding this proposal on the staff side?
 

Venia Silente

Inspectious. Good for napping.
1,230
Posts
15
Years
For the record, while I haven't seen this used anywhere except in very old Jupitermedia forums (old like, back then at 2005-ish), some BBCode parsers do accept stuff like [code="c++"] or [code="python3"]. I have no idea how do they do it but I would presume they would offload the actual syntax highlighting to a library like GeSHI, just as wiki softwares like DokuWiki do.

I don't know if there is enough code-posting activity in the ROM Hacking section so as to merit evaluating it, alas, but depending on what is wanted "fixing" the code tag might be worth it.

I would think that the ability to link to or embed a Gist and or other forms of repository code post (even if the only one that comes to mind right now is Fossil artifacts) would work nicely and probably be more welcome though. Styling and properties would be uniform, and if the creator changes or fixes something, the thread here sees the changes.
 
Back
Top