What's new

BBCode Syntax Help?

  • Thread starter Kankuro
  • Start date
  • Views 520
Kankuro

Kankuro

How To Do?
VIP
Retired
Messages
8,972
Reaction score
7,956
Points
2,210
Sin$
0
I'm trying to add code Synthax to codes, the following code works well, however the codes within the [ code] bbcode aren't displaying properly (line breaks) and it displaying completely inline. Can anybody help me with this issue?

<head>
HTML:
<link rel="stylesheet" type="text/css" href="http://z3.ifrm.com/63/1/0/p509771/prism.css" />

<body>
JavaScript:
<script type="text/javascript">
function addLang(nClass, nName) {
    $('blockquote dt:contains(' + nClass + ')').parents('blockquote').find('code').addClass('language-' + nClass);
    $('blockquote dt:contains(' + nClass + ')').text('Code: ' + nName);
}

addLang('css', 'CSS');
addLang('javascript', 'JavaScript');
addLang('php', 'PHP');
addLang('sql', 'SQL');
addLang('c++', 'C++');
addLang('c#', 'C#');
addLang('python', 'Python');
addLang('java', 'Java');
</script>
<script type="text/javascript" src="http://z3.ifrm.com/63/1/0/p509772/prism.js"></script>


Here is how it displays: http://i.imgur.com/I67HO7I.png
 
Last edited:
Xeren

Xeren

♦♦♦ God Complex ♦♦♦
Legendary Veteran Programmer Modder
Messages
5,668
Reaction score
2,107
Points
795
Sin$
0
I'm trying to add code Synthax to codes, the following code works well, however the codes within the [ code] bbcode aren't displaying properly (line breaks) and it displaying completely inline. Can anybody help me with this issue?

<head>
HTML:
<link rel="stylesheet" type="text/css" href="http://z3.ifrm.com/63/1/0/p509771/prism.css" />

<body>
JavaScript:
<script type="text/javascript">
function addLang(nClass, nName) {
    $('blockquote dt:contains(' + nClass + ')').parents('blockquote').find('code').addClass('language-' + nClass);
    $('blockquote dt:contains(' + nClass + ')').text('Code: ' + nName);
}

addLang('css', 'CSS');
addLang('javascript', 'JavaScript');
addLang('php', 'PHP');
addLang('sql', 'SQL');
addLang('c++', 'C++');
addLang('c#', 'C#');
addLang('python', 'Python');
addLang('java', 'Java');
</script>
<script type="text/javascript" src="http://z3.ifrm.com/63/1/0/p509772/prism.js"></script>


Here is how it displays: http://i.imgur.com/I67HO7I.png
Use the "pre" tag.
 
Kankuro

Kankuro

How To Do?
VIP
Retired
Messages
8,972
Reaction score
7,956
Points
2,210
Sin$
0
Use the "pre" tag.
It's wrapped in a span tag. How do I change that? Keep in mind that the site I'm using it on is a free hoster so it's client-side not server-side.
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
It's wrapped in a span tag. How do I change that? Keep in mind that the site I'm using it on is a free hoster so it's client-side not server-side.
You could just keep it in the span tag and add pre within it.
 
Xeren

Xeren

♦♦♦ God Complex ♦♦♦
Legendary Veteran Programmer Modder
Messages
5,668
Reaction score
2,107
Points
795
Sin$
0
It's wrapped in a span tag. How do I change that? Keep in mind that the site I'm using it on is a free hoster so it's client-side not server-side.
I'm assuming you can edit the site via jQuery? Simply find the "span" tags and replace them with "pre" tags.
Code:
$('span').replaceWith(function(){ return $("<pre />", {html: $(this).html()}); });

Or you'd have to add a "pre" tag to the spans, and then move the previous children to it.
 
Kankuro

Kankuro

How To Do?
VIP
Retired
Messages
8,972
Reaction score
7,956
Points
2,210
Sin$
0
You could just keep it in the span tag and add pre within it.
How?

I'm assuming you can edit the site via jQuery? Simply find the "span" tags and replace them with "pre" tags.
Code:
$('span').replaceWith(function(){ return $("<pre />", {html: $(this).html()}); });

Or you'd have to add a "pre" tag to the spans, and then move the previous children to it.
I can use jQuery yes, but changing ALL the spans to pres would ruin tons of other codes I use.
 
Xeren

Xeren

♦♦♦ God Complex ♦♦♦
Legendary Veteran Programmer Modder
Messages
5,668
Reaction score
2,107
Points
795
Sin$
0
How?


I can use jQuery yes, but changing ALL the spans to pres would ruin tons of other codes I use.
You'd use the same heading as you used to add the syntax class.
Code:
$('blockquote dt:contains(' + nClass + ')').parents('blockquote').find('code').find('span')
 
Top Bottom
Login
Register