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

Tick notation is interpreted as quotes #6

Closed
ramanshah opened this issue Jan 17, 2017 · 16 comments
Closed

Tick notation is interpreted as quotes #6

ramanshah opened this issue Jan 17, 2017 · 16 comments

Comments

@ramanshah
Copy link

First of all, I'm really enjoying the 99 Haskell problems and did a bunch of them this weekend as I try to start getting fluency with Haskell in earnest. Thanks!

The tick character ' used to denote alternative implementations of a function are being interpreted as single quotes in a language where single quotes denote multi-line strings. To wit, in the solution to question 1:

<haskell>
myLast :: [a] -> a
myLast [] = error "No end for empty lists!"
myLast [x] = x
myLast (_:xs) = myLast xs

myLast' = foldr1 (const id)

-- Prelude> const 1 2
-- 1
-- Prelude> (flip const) 1 2
-- 2
myLast'' = foldr1 (flip const)

myLast''' = head . reverse

myLast'''' = foldl1 (curry snd)

myLast''''' [] = error "No end for empty lists!"  
myLast''''' x = x !! (length x -1)

</haskell>

looks like this:

image

@ppelleti
Copy link
Contributor

Thanks for the bug report! I agree that this is a problem that needs to be fixed!

To calibrate expectations: I'm new to this job (and by "job" I mean volunteering), and don't know a whole lot about the wiki yet. So it might take a while for me to fix this. But I will definitely look into it when I get a chance!

@ramanshah
Copy link
Author

Of course, we're all volunteers :)

I don't know the first thing about the wiki rendering system. If you can point me to documentation, I can look at it, too, to try and figure if and how one can configure its tokenizer.

@ppelleti
Copy link
Contributor

Thanks! I'm afraid I know about as much as you do. I suspect there's a plug-in for syntax highlighting, but I'll need to do a little research to find its name and documentation.

@ppelleti
Copy link
Contributor

According to Special:Version, the wiki is using the SyntaxHighlight extension, which in turn uses GeSHi - Generic Syntax Highlighter.

It appears that the current version of SyntaxHighlight uses pygments instead of GeSHi. So I should probably look into upgrading to the latest version of SyntaxHighlight, and see if pygments handles Haskell syntax better than GeSHi does.

@ppelleti
Copy link
Contributor

I'm unclear where the <haskell> tag is coming from, though, because the SyntaxHighlight documentation only mentions <syntaxhighlight> and <source> as tags, with lang as an attribute. It doesn't say anything about being able to use a language name as a tag name. I wonder if that is some sort of customization specific to the Haskell wiki?

@gbaz
Copy link
Collaborator

gbaz commented Jan 18, 2017

I checked the LocalSettings.php of our wiki, and found the following:


# Make <haskell> a synonym for <source lang='haskell'>.
#
# The following is pretty hackish, but otherwise we'd have to edit the
# extension code.
function haskellKeywordHook( $text, $args = array(), $parser ) {
  $args["lang"] = "haskell";
  return SyntaxHighlight_GeSHi::parserHook( $text, $args, $parser );
}

function haskKeywordHook( $text, $args = array(), $parser ) {
  $args['lang'] = 'haskell';
  $args['enclose'] = 'div';
  $out = SyntaxHighlight_GeSHi::parserHook( $text, $args, $parser );
  return '<div class="inline-code">' . $out . '</div>';
}


function addHaskellKeywordHook() {
  global $wgParser;
  $wgParser->setHook( 'haskell', 'haskellKeywordHook' );
  $wgParser->setHook( 'hask', 'haskKeywordHook' );
  return true;
}

@ppelleti
Copy link
Contributor

Thanks, @gbaz ! It sounds then like upgrading SyntaxHighlight won't affect the ability of the <haskell> tag to work.

On the other hand, it looks like upgrading SyntaxHighlight won't be straightforward, because the current version of SyntaxHighlight requires MediaWiki 1.23 or higher, and we only have MediaWiki 1.19. So going to the latest SyntaxHighlight would require upgrading MediaWiki, which would probably be a good thing, but sounds pretty scary, given how little I still understand. I'm very afraid I would break something.

@ramanshah
Copy link
Author

Maybe one thing I can offer is to run the above solution through pygments to verify if that will help.

@ramanshah
Copy link
Author

Yay, pygments has a nice web interface for demo purposes:

http://pygments.org/demo/6344635/

In case of broken links, it looks good and certainly resolves the title issue with the rendering:

image

@ramanshah
Copy link
Author

Also relevant: The underlying issue appears to have been fixed in GeSHi, in case a GeSHi upgrade is easier than an upgrade of the wiki engine to support pygments:

GeSHi/geshi-1.0#46

@ramanshah
Copy link
Author

Hmm, but it looks like they stopped cutting releases years ago.

@ppelleti
Copy link
Contributor

Thanks, @ramanshah ! I might look into updating GeSHi, since that seems easier and lower risk.

On the other hand, we now have another request, #7, to upgrade MediaWiki. Apparently there are some security issues with the version we're running. So maybe I should just bite the bullet and upgrade MediaWiki.

@ppelleti
Copy link
Contributor

I've been attempting to upgrade GeSHi, but so far I've been unsuccessful.

GeSHi is installed in /usr/share/php-geshi, as part of the php-geshi apt package. There is no newer version of the php-geshi package available, so we can't upgrade with apt.

PHP's package manager appears to be called PEAR. I installed PEAR and attempted to use it, but PEAR doesn't seem to know anything about a package named geshi or GeSHi.

The GeSHi documentation suggests just installing by copying files. So, I checked out the geshi-1.0 Git repository into wikiadmin's home directory. I moved the existing /usr/share/php-geshi to /usr/share/php-geshi-old, and then created a new /usr/share/php-geshi. I copied the geshi.php and geshi directory from the Git checkout to /usr/share/php-geshi.

I wasn't sure if anything needed to be restarted to pick up the changed files, so I did service nginx restart and service php5-fpm restart for good measure.

However, after doing all this, the syntax highlighting is still incorrect. Not sure what to try next.

@ppelleti
Copy link
Contributor

OK, it looks like there was some sort of caching going on. I edited the Sandbox page, and now it looks OK. So I think the problem is fixed, but you'll need to make a trivial edit to each page that has incorrect highlighting, to defeat the cache.

I'm going to mark this as closed, but please let me know if you run into any issues.

@jhenligne
Copy link

jhenligne commented Feb 14, 2017 via email

@ramanshah
Copy link
Author

Wonderful! Thanks for fixing this, Patrick!

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

No branches or pull requests

4 participants