Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvement to latex highlighting code #132

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

tormec
Copy link

@tormec tormec commented Feb 23, 2020

Hello,
this is my revision about how GeSHi highlights latex code.
Refer to the "changes" section in the same script for what I've done.
The image attached provides the final result (on the right) compared to the actual rendering.
latex-geshi

@@ -2060,7 +2060,7 @@
'REGEXPS' => array(
// environment
1 => array(
GESHI_SEARCH => '(?<=\\\\)(begin|end)(\{)(\w*)(\})',
GESHI_SEARCH => '(?<=\\\\)(begin|end)(\{)([\w\*]*)(\})',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now match also

\begin{align*}
...
\end{align*}

@tormec
Copy link
Author

tormec commented Mar 30, 2020

The list of LaTex packages has been made with the following script

<?php
$tag = '<div class="dt"><a href="/pkg/';
$alphabet = array(
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
    'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
$packages = array();
foreach ($alphabet as $pg) {
    $content = file('https://ctan.org/pkg/:'.$pg);
    foreach ($content as $row) {
        $row = trim($row);
        if (strpos($row, $tag) !== false) {
            $packages[]= strstr(substr($row, strlen($tag)), '"', true);
        }
    }
}
$multi_str = '';
$str = '';
asort($packages);
foreach ($packages as $key => $val) {
    $str .= "'" . $val . "'" . ', ';
    if (strlen($str) >= 100 || $key == array_key_last($packages)) {
        $str .= '<br>';
        $multi_str .= $str;
        $str = '';
    }
}
echo $multi_str;

each keyword row spans 100 characters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant