Author Topic: Code blocks  (Read 9626 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Code blocks
« on: March 25, 2013, 09:59:17 AM »
Can you guys please use the built-in code blocks until we can figure out why the GeSHi mod is giving us so many errors.

thanks
TheSwamp.org  (serving the CAD community since 2003)

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Code blocks
« Reply #1 on: March 25, 2013, 10:19:46 AM »
Do you mean the code tags without attribute for example code=csharp, etc......
Sorry was not sure what you meant.

Thanks.

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Code blocks
« Reply #2 on: March 25, 2013, 10:19:53 AM »
No problem Mark  :-)

To clarify, I assume you are requesting we enclose our code using:

[code]Your code here[/code]
« Last Edit: March 25, 2013, 10:36:26 AM by Lee Mac »

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: Code blocks
« Reply #3 on: March 25, 2013, 11:45:28 AM »
Do you mean the code tags without attribute for example code=csharp, etc......
Yes, that is what I meant.

thanks
TheSwamp.org  (serving the CAD community since 2003)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Code blocks
« Reply #4 on: March 25, 2013, 11:53:19 AM »

I learned something

 [ nobbc ] unparsed content [ /nobbc ]
  [color=red][size=14pt]unparsed content[/size] [/color]

quote the post to help visualise
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Code blocks
« Reply #5 on: March 25, 2013, 01:47:41 PM »

I learned something

 [ nobbc ] unparsed content [ /nobbc ]
  [color=red][size=14pt]unparsed content[/size] [/color]

quote the post to help visualise

There is also a noparse tag.

-David
R12 Dos - A2K

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Code blocks
« Reply #6 on: March 26, 2013, 11:29:27 AM »
Do we still need to avoid using modifiers, attributes, not sure correct name?

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Code blocks
« Reply #7 on: April 05, 2013, 10:33:49 AM »
Update: I am going to start over (redo the entire `code block' mods). ...I'm not sure if I screwed up or if its a PHP/MySql error at this point.  Something is tossing a error and the forum/server gets thousands of them a day.

TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Code blocks
« Reply #8 on: April 05, 2013, 11:05:11 AM »
Pushed another attempt (rechecked my previous work and pushed it on the server again).

« Last Edit: April 05, 2013, 11:28:51 AM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: Code blocks
« Reply #9 on: April 05, 2013, 11:11:32 AM »
Code: [Select]
I always use code blocks. I don't know the correct syntax for colorized code when I need it so I take the simple version.
The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Code blocks
« Reply #10 on: April 05, 2013, 11:35:06 AM »
huiz,
The colored code blocks were intended to be used by users to understand your code better (your choice to use them or not). The autolisp code blocks offered hyperlinks to a "man page" that offered syntax help to new users.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Code blocks
« Reply #11 on: April 05, 2013, 01:13:44 PM »

Thanks John !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Code blocks
« Reply #12 on: April 05, 2013, 03:27:20 PM »
:) But it's still broke though.
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Code blocks
« Reply #13 on: April 07, 2013, 08:41:38 PM »
How so ?
What sort of errors ?
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

JohnK

  • Administrator
  • Seagull
  • Posts: 10626
Re: Code blocks
« Reply #14 on: April 08, 2013, 10:45:12 AM »
We are getting an error that says there is an error converting an array to string.

Code: [Select]
https://www.theswamp.org/index.php?topic=44258.0;prev_next=prev8:
Array to string conversion
File: Subs.php
Line: 2322

line 2322: $code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));

Heres the IF block (starting on line 2265, line 36 in this snip is where the error occurs):
Code: [Select]
// Don't parse the content, just skip it.
elseif ($tag['type'] == 'unparsed_equals_content')
{
// The value may be quoted for some tags - check.
if (isset($tag['quoted']))
{
$quoted = substr($message, $pos1, 6) == '&quot;';
if ($tag['quoted'] != 'optional' && !$quoted)
continue;

if ($quoted)
$pos1 += 6;
}
else
$quoted = false;

$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
if ($pos2 === false)
continue;
$pos3 = stripos($message, '[/' . substr($message, $pos + 1, strlen($tag['tag'])) . ']', $pos2);
if ($pos3 === false)
continue;

$data = array(
substr($message, $pos2 + ($quoted == false ? 1 : 7), $pos3 - ($pos2 + ($quoted == false ? 1 : 7))),
substr($message, $pos1, $pos2 - $pos1)
);

if (!empty($tag['block_level']) && substr($data[0], 0, 6) == '<br />')
$data[0] = substr($data[0], 6);

// Validation for my parking, please!
if (isset($tag['validate']))
$tag['validate']($tag, $data, $disabled);

$code = strtr($tag['content'], array('$1' => $data[0], '$2' => $data[1]));
$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + strlen($tag['tag']));
$pos += strlen($code) - 1 + 2;
}
// A closed tag, with no content or value.
elseif ($tag['type'] == 'closed')
{
$pos2 = strpos($message, ']', $pos);
$message = substr($message, 0, $pos) . "\n" . $tag['content'] . "\n" . substr($message, $pos2 + 1);
$pos += strlen($tag['content']) - 1 + 2;
}
// This one is sorta ugly... :/.  Unfortunately, it's needed for flash.
elseif ($tag['type'] == 'unparsed_commas_content')
{
$pos2 = strpos($message, ']', $pos1);
if ($pos2 === false)
continue;
$pos3 = stripos($message, '[/' . substr($message, $pos + 1, strlen($tag['tag'])) . ']', $pos2);
if ($pos3 === false)
continue;

// We want $1 to be the content, and the rest to be csv.
$data = explode(',', ',' . substr($message, $pos1, $pos2 - $pos1));
$data[0] = substr($message, $pos2 + 1, $pos3 - $pos2 - 1);

if (isset($tag['validate']))
$tag['validate']($tag, $data, $disabled);

$code = $tag['content'];
foreach ($data as $k => $d)
$code = strtr($code, array('$' . ($k + 1) => trim($d)));
$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos3 + 3 + strlen($tag['tag']));
$pos += strlen($code) - 1 + 2;
}
// This has parsed content, and a csv value which is unparsed.
elseif ($tag['type'] == 'unparsed_commas')
{
$pos2 = strpos($message, ']', $pos1);
if ($pos2 === false)
continue;

$data = explode(',', substr($message, $pos1, $pos2 - $pos1));

if (isset($tag['validate']))
$tag['validate']($tag, $data, $disabled);

// Fix after, for disabled code mainly.
foreach ($data as $k => $d)
$tag['after'] = strtr($tag['after'], array('$' . ($k + 1) => trim($d)));

$open_tags[] = $tag;

// Replace them out, $1, $2, $3, $4, etc.
$code = $tag['before'];
foreach ($data as $k => $d)
$code = strtr($code, array('$' . ($k + 1) => trim($d)));
$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + 1);
$pos += strlen($code) - 1 + 2;
}
// A tag set to a value, parsed or not.
elseif ($tag['type'] == 'unparsed_equals' || $tag['type'] == 'parsed_equals')
{
// The value may be quoted for some tags - check.
if (isset($tag['quoted']))
{
$quoted = substr($message, $pos1, 6) == '&quot;';
if ($tag['quoted'] != 'optional' && !$quoted)
continue;

if ($quoted)
$pos1 += 6;
}
else
$quoted = false;

$pos2 = strpos($message, $quoted == false ? ']' : '&quot;]', $pos1);
if ($pos2 === false)
continue;

$data = substr($message, $pos1, $pos2 - $pos1);

// Validation for my parking, please!
if (isset($tag['validate']))
$tag['validate']($tag, $data, $disabled);

// For parsed content, we must recurse to avoid security problems.
if ($tag['type'] != 'unparsed_equals')
$data = parse_bbc($data, !empty($tag['parsed_tags_allowed']) ? false : true, '', !empty($tag['parsed_tags_allowed']) ? $tag['parsed_tags_allowed'] : array());

$tag['after'] = strtr($tag['after'], array('$1' => $data));

$open_tags[] = $tag;

$code = strtr($tag['before'], array('$1' => $data));
$message = substr($message, 0, $pos) . "\n" . $code . "\n" . substr($message, $pos2 + ($quoted == false ? 1 : 7));
$pos += strlen($code) - 1 + 2;
}


EDIT:
I needed to keep this link for myself.
http://www.roseindia.net/tutorial/php/phpbasics/PHP-Array-to-String.html
« Last Edit: April 08, 2013, 04:02:41 PM by Se7en »
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org