News:

SMF - Just Installed!

Main Menu

Bienvenidos a nuestra página

Started by Moyack, Oct 09, 2021, 01:09 PM

Previous topic - Next topic

Moyack

Bienvenidos!!

En esta página encontrarás información acerca del uso adecuado de herramientas, así como recomendaciones y top listing de los mejores productos en su sector o categoría.

Probando LCODE: LCODE simple: This is a simple text. LCODE con lenguaje definido: file_get_contents('./testgeshi.php', true);.

  1. # GeSHi21 User Manual
  2. **Version:** 2.1.0
  3. GeSHi21 is a modern PHP syntax highlighting engine inspired by GeSHi 1.0. It provides a clean, object‑oriented API for highlighting source code in various programming languages using language definition files.
  4. ---
  5. ## Installation
  6. Place the `geshi21.php` file in your project and create a directory for language files (e.g., `geshi/`). Download language definition files from the GeSHi 1.0 repository and place them in this directory.

Code (php) Select
  1. <?php
  2. if (!defined('SMF'))
  3.    die('No direct access...');
  4. /**
  5. * Function linked to the integrate_bbc_codes hook.
  6. *
  7. * @param array $codes Array of BB codes passed by reference.
  8. */
  9. function geshi21_add_bbc(&$codes)
  10. {
  11.    global $sourcedir, $settings, $txt, $disabled;
  12.    // Remove native definitions of the 'code' tag
  13.    $codes = array_filter($codes, function ($code) {
  14.            return $code['tag'] !== 'code';
  15.        });
  16.    // Insert the [code] tag without parameters
  17.    $codes[] = array(
  18.        'tag' => "code",
  19.        'type' => 'unparsed_content',
  20.        'content' => '<div class="codeheader"><span class="code floatleft">' . $txt['code'] . '</span> <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="' . $txt['code_shrink'] . '" data-expand-txt="' . $txt['code_expand'] . '">' . $txt['code_expand'] . '</a></div><code class="bbc_code">$1</code>',
  21.        'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($sourcedir, $settings)
  22.        {
  23.            require_once($sourcedir . '/GeSHi21/geshi21.php');
  24.            $data = strtr($data, array(
  25.                '[]'    => '[]',
  26.                '[&#039;' => '[&#039;',
  27.                '<br />'    => "\n",
  28.            ));
  29.            $data = un_htmlspecialchars($data);
  30.            $geshi = new GeSHi($data, 'text');
  31.            $geshi->set_overall_class('geshi');
  32.            $geshi->set_header_type(GESHI_HEADER_PRE);
  33.            $data = str_replace("\n", "", $geshi->parse_code());
  34.        },
  35.        'block_level' => true,
  36.    );
  37.    // Insert the [code=language] tag with parameters
  38.    $codes[] = array(
  39.        'tag' => 'code',
  40.        'type' => 'unparsed_equals_content',
  41.        'content' => '$1',
  42.        'validate' => isset($disabled['code']) ? null : function(&$tag, &$data, $disabled) use ($sourcedir, $settings, $txt)
  43.        {
  44.            $data[0] = un_htmlspecialchars(str_replace(['[]', '[&#039;', '<br />'], ['[]', '[&#039;', "\n"], $data[0]));
  45.            $data[0] = un_htmlspecialchars(htmlentities($data[0]));
  46.            $data[1] = explode(',', $data[1]);
  47.            
  48.            require_once($sourcedir . '/GeSHi21/geshi21.php');
  49.            $geshi = new GeSHi($data[0], $data[1][0]);
  50.            
  51.            $geshi->set_overall_class('geshi');
  52.            if (isset($data[1][1]) && is_numeric($data[1][1]))
  53.                $geshi->start_line_numbers_at($data[1][1]);
  54.            if (count($data[1]) > 1)
  55.            {
  56.                $data[1] = array_filter($data[1], 'is_numeric');
  57.                if (!empty($settings['geshi_highlight_lines_extra_style']) && strlen(trim($settings['geshi_highlight_lines_extra_style'])))
  58.                    $geshi->set_highlight_lines_extra_style($settings['geshi_highlight_lines_extra_style']);
  59.                
  60.                $geshi->highlight_lines_extra($data[1]);
  61.            }
  62.            $geshi->enable_classes(true);
  63.            $geshi->set_header_type(GESHI_HEADER_PRE);
  64.            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
  65.            
  66.            if (isset($settings['geshi_line_style']) && isset($settings['geshi_line_style_fancy']))
  67.                $geshi->set_line_style($settings['geshi_line_style'], $settings['geshi_line_style_fancy']);
  68.            if (!empty($settings['geshi_enable_header']) && isset($settings['geshi_header']))
  69.                $geshi->set_header_content($settings['geshi_header']);
  70.            
  71.            if (!empty($settings['geshi_enable_footer']) && isset($settings['geshi_footer']))
  72.                $geshi->set_footer_content($settings['geshi_footer']);
  73.            //var_dump($data[0]);
  74.            $data[0] = '
  75.            <div class="codeheader">
  76.                <span class="code floatleft">' . $txt['code'] . '</span> ('. $geshi->get_language() .') <a class="codeoperation smf_select_text">' . $txt['code_select'] . '</a> <a class="codeoperation smf_expand_code hidden" data-shrink-txt="' . $txt['code_shrink'] . '" data-expand-txt="' . $txt['code_expand'] . '">' . $txt['code_expand'] . '</a></div>
  77.                <code class="bbc_code">'. $geshi->parse_code() .'</code>
  78.            </div>';
  79.            
  80.            //echo '<pre>' . print_r($data) . '</pre>';
  81.        },
  82.        'block_level' => true,
  83.    );
  84. }
  85. function geshi21_load_theme()
  86. {
  87.    loadCSSFile('geshi_modern.css', array('default_theme' => true), 'geshi21');
  88. }
  89. ?>

Code (lua) Select
  1. -- Single-line comments start with a double dash
  2. -- [[ Multi-line comments look like this ]]
  3. -----------------------------------------
  4. -- 1. VARIABLES & DATA TYPES
  5. -----------------------------------------
  6. -- Variables are global by default; always use 'local' to scope them properly
  7. local name = "Developer"          -- String
  8. local age = 26                    -- Number (all numbers are doubles/integers)
  9. local isLearning = true           -- Boolean
  10. local emptyValue = nil            -- Represents the absence of data
  11. -----------------------------------------
  12. -- 2. TABLES (Arrays and Dictionaries)
  13. -----------------------------------------
  14. -- Arrays are 1-indexed in Lua
  15. local shoppingList = {"Apples", "Bananas", "Oranges"}
  16. -- Tables also act as dictionaries/objects
  17. local userProfile = {
  18.    username = "LuaCoder",
  19.    level = 5,
  20.    isPremium = false
  21. }
  22. -----------------------------------------
  23. -- 3. FUNCTIONS
  24. -----------------------------------------
  25. -- A standard function that takes parameters and returns a value
  26. local function calculateBonus(score, multiplier)
  27.    if not score then return 0 end -- Early exit if nil
  28.    return score * multiplier
  29. end
  30. -----------------------------------------
  31. -- 4. CONTROL FLOW & LOOPS
  32. -----------------------------------------
  33. -- Conditional block
  34. if userProfile.level >= 5 then
  35.    print("Welcome high-level user: " .. userProfile.username) -- '..' concatenates strings
  36. elseif userProfile.level > 1 then
  37.    print("Keep playing!")
  38. else
  39.    print("Welcome beginner!")
  40. end
  41. -- Numeric For Loop: (start, stop, step)
  42. print("--- Counting up ---")
  43. for i = 1, 3, 1 do
  44.    print("Count: " .. i)
  45. end
  46. -- Iterating through an Array (using ipairs)
  47. print("--- Shopping List ---")
  48. for index, item in ipairs(shoppingList) do
  49.    print(index .. ": " .. item)
  50. end
  51. -- Iterating through a Dictionary (using pairs)
  52. print("--- User Profile ---")
  53. for key, value in pairs(userProfile) do
  54.    print(key .. " = " .. tostring(value))
  55. end
  56. -----------------------------------------
  57. -- 5. EXECUTING A FUNCTION
  58. -----------------------------------------
  59. local finalScore = calculateBonus(100, 1.5)
  60. print("Final calculated bonus score: " .. finalScore)

Code (xml) Select
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <breakfast_menu>
  3. <food>
  4.    <name>Belgian Waffles</name>
  5.    <price>$5.95</price>
  6.    <description>
  7.  Two of our famous Belgian Waffles with plenty of real maple syrup
  8.  </description>
  9.    <calories>650</calories>
  10. </food>
  11. <food>
  12.    <name>Strawberry Belgian Waffles</name>
  13.    <price>$7.95</price>
  14.    <description>
  15.    Light Belgian waffles covered with strawberries and whipped cream by John's sister
  16.    </description>
  17.    <calories>900</calories>
  18. </food>
  19. <food>
  20.    <name>Berry-Berry Belgian Waffles</name>
  21.    <price>$8.95</price>
  22.    <description>
  23.    Belgian waffles covered with assorted fresh berries and whipped cream
  24.    </description>
  25.    <calories>900</calories>
  26. </food>
  27. <food>
  28.    <name>French Toast</name>
  29.    <price>$4.50</price>
  30.    <description>
  31.    Thick slices made from our homemade sourdough bread
  32.    </description>
  33.    <calories>600</calories>
  34. </food>
  35. <!-- This is a comment -->
  36. <food>
  37.    <name>Homestyle Breakfast</name>
  38.    <price>$6.95</price>
  39.    <description>
  40.    Two eggs, bacon or sausage, toast, and our ever-popular hash browns
  41.    </description>
  42.    <calories>950</calories>
  43. </food>
  44. </breakfast_menu>

Code (html) Select
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. p.error {
  6.  color: red;
  7. }
  8. </style>
  9. </head>
  10. <body>
  11. <p>This is a paragraph.</p>
  12. <p>This is a paragraph.</p>
  13. <p class="error">I am different.</p>
  14. <p>This is a paragraph.</p>
  15. <!-- This is a comment -->
  16. <p class="a b c-f">I am <b>different</b> too. Let's check some letlers t b i strong</p>
  17. </body>
  18. </html>