JScript

Programação & Desenvolvimento


Você não está conectado. Conecte-se ou registre-se

Problema com Syntax Highlighter

2 participantes

Ir para baixo  Mensagem [Página 1 de 1]

1Problema com Syntax Highlighter Empty Problema com Syntax Highlighter Seg 09 Set 2013, 7:40 am

Convidado

avatar
Convidado

Olá, Convidado.

Tentei instalar o Syntax Highlighter, mas não está reconhecendo o código.

Problema com Syntax Highlighter Gte0JCM


Link do fórum: http://programeiros.maisforum.com/


Até mais.

Obrigado.

2Problema com Syntax Highlighter Empty Re: Problema com Syntax Highlighter Seg 09 Set 2013, 12:20 pm

Legolas

Legolas
Moderadores
Moderadores

O que aconteceu foi o seguinte: você adicionou o script sem as tags <script>.

Veja abaixo como deve ser usado. Substitua o código por este:
Código:
<script language="javascript" type="text/javascript">

/* Syntax Highlighter by JScript - 2013-07-17 | http://jscript.forumeiros.com */
        jQuery(function () {
            jQuery('code').each(function () {
                var sContent = jQuery(this).html();
                var codebox = jQuery(this).parent().parent();
                codebox.before('<div class="punbbtop">PunBB &nbsp; &nbsp; &nbsp; &nbsp;<button onclick="punbbExpand(this); return false;">expand</button><button style="display: none" onclick="punbbCollapse(this); return false;">collapse</button>&nbsp; <button onclick="punbbSelect(this); return false;">select</button>&nbsp; <button onclick="punbbPopup(this); return false;">popup</button>&nbsp; <button style="margin-right: 50px; float: right;" onclick="punbbAbout(this); return false;">?</button></div></div></div><pre class="highlight punbb_block">' + sContent + '</pre>');
                codebox.remove();
            });
            jQuery.getScript('http://balupton.github.com/jquery-syntaxhighlighter/scripts/jquery.syntaxhighlighter.min.js', function () {
                jQuery.SyntaxHighlighter.init({
                    'wrapLines': false
                })
            })
        });
        function punbbExpand(oThis) {
            jQuery(oThis).css('display', 'none');
            jQuery(oThis).next().css('display', '');
            jQuery(oThis).parent().next('pre.punbb_block').addClass('expand');       
        }
        function punbbCollapse(oThis) {
            jQuery(oThis).css('display', 'none');
            jQuery(oThis).prev().css('display', '');
            /*jQuery(oThis).parent().parent().find('pre.punbb_block').css('height', '250px;');*/
            jQuery(oThis).parent().next('pre.punbb_block').removeClass('expand');
        }
        function punbbPopup(oThis) {
            var content = jQuery(oThis).parent().next('pre.punbb_block').html();
            var my_window = window.open("", "PunBB code - Para selecionar o código: [Ctrl] + [A]", "scrollbars=1toolbar=no,menubar=no,personalbar=no,status=0,left=0,location=0,menubar=0,top=0,width=640,height=480");
            my_window.document.write('<pre>'+content+'</pre>');
        }
        function punbbAbout(oThis) {
            alert('Simple code to add Syntax Highlighter fuctionality for PunBB-Forumeiros\n\nBy JScript FROM Brazil - 2013/07/17\n');
        }
        function punbbSelect(oThis) {
            var doc = document;
            var text = jQuery(oThis).parent().next('pre.punbb_block')[0];
            if (doc.body.createTextRange) {
                var range = doc.body.createTextRange();
                range.moveToElementText(text);
                range.select();
            } else if (window.getSelection) {
                var selection = window.getSelection();
                var range = doc.createRange();
                range.selectNodeContents(text);
                selection.removeAllRanges();
                selection.addRange(range);       
            }
        }           

</script>

http://aden.rpgwars.net

3Problema com Syntax Highlighter Empty Re: Problema com Syntax Highlighter Seg 09 Set 2013, 7:19 pm

Convidado

avatar
Convidado

Olá, isto resolveu o problema de leitura do código, mas mesmo assim ele não funcionou dentro do fórum.

Só tirando uma dúvida ele vai substituir ao CODE?

Problema com Syntax Highlighter XHQXaVr

4Problema com Syntax Highlighter Empty Re: Problema com Syntax Highlighter Seg 09 Set 2013, 7:35 pm

JScript

JScript
Administradores
Administradores

@Hastag
Como nosso amigo @Legolas afirmou acima que faltou a tag <script> pois eu não informei no tutorial, também esqueci de mencionar que deve ser adicionado dentro da tag <head> mas no final dela que é antes de </head>!

Basta você mover o código para o final da tag head, que significa que deve ser antes de </head>, percebendo estes inconvenientes, vou adicionar no tutorial a explicação a respeito disto.

Edit: Pode ser colocado abaixo ou acima de {HOSTING_JS}

JS



Última edição por JScript em Seg 09 Set 2013, 7:58 pm, editado 1 vez(es)

http://autoitbrasil.com

5Problema com Syntax Highlighter Empty Re: Problema com Syntax Highlighter Seg 09 Set 2013, 7:57 pm

Convidado

avatar
Convidado

Perfeito. Obrigado pela solução.
Até mais.

Conteúdo patrocinado



Ir para o topo  Mensagem [Página 1 de 1]

Permissões neste sub-fórum
Não podes responder a tópicos