Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

inline php #107

Closed
akzhan opened this Issue · 35 comments
@akzhan

We often need to highlight PHP code without start <?php marker.

Its easy using Pygments - by set startinline option to true.

But how ho implement this using GFM?

Something like phpi language identifier?

@nickl-

I believe this has been resolved when using ```php as the opening of the code block.

I did discover one problem though, the php function substr is not recognized. see substr in manual

/** comments about stuff */
echo "Some stuff echoed";

print_r(array('and' => 'other things all well'));

$str = "Some very long string that we want to cut shorter";

/** this is a problem though */
phpinfo();                         // a php function
my_function();                     // a custom function
echo substr($str, 0, 16);          // not recognized as php function
echo substr($str, -14);            // should look like the other php functions
echo mb_substr($str, 0, 16);       // a php function
echo chunk_split($str, 16, "\n");  // a php function

Is exactly the same as with the <?php added,

<?php
/** comments about stuff */
echo "Some stuff echoed";

print_r(array('and' => 'other things all well'));


/** this is a problem though */
phpinfo();                         // a php function
my_function();                     // a custom function
echo substr($str, 0, 16);          // not recognized as php function
echo substr($str, -14);            // should look like the other php functions
echo mb_substr($str, 0, 16);       // a php function
echo chunk_split($str, 16, "\n");  // a php function

Awesome stuff guys thanx!!! This is going to make php snippets much tidier. You rock! Keep up the good work.

@nickl-

Issue can be closed

@Topener

It looks like it is fixed for comments, but not for the Github wiki. Should be implemented there too! Issue should remain open!

@opensourceame

The wiki is probably the most important place that inline markup is needed. Issue comments are not read nearly as much as documentation!

@Dayjo

Would really appreciate this being done for the wiki. Seems a waste of space to have a start <?php tag at the beginning of every small code block.

@daithi-coombes

+1 from me for setting startinline option to true

@gjtorikian gjtorikian closed this
@ureimers

This also doesn't work on Gist. Without this Stackoverflow answer my text still wouldn't be highlighted, because I wasn't expecting the <?php tag to be mandatory.

@opensourceame

Also still not working for the Wiki. Can we re-open this issue please?

@Topener

I also vote for reopening. It still doesn't work

@daithi-coombes

double voting on this... don't see why it was closed

@gjtorikian gjtorikian reopened this
@gjtorikian
Owner

Sorry, totally glossed over after reading "Issue can be closed".

@Dayjo

Also happy to double vote up! :+1:

@Topener

good thing we are open again.

@nickl-

@gjtorikian that link to comment would look so much better like this

#158-11622364

=)

@kprovance

Add my vote for startinline option to true for php wiki highlighting without the bloody opening tag.

@pnm1231

Is this getting fixed any soon?

@opensourceame

Still waiting, this is now a year old, please can someone at GitHub look into this.

@bkeepers
Owner

Syntax highlighting for markdown in Wikis should work the same as on the rest of the site now. It will be fixed for non-markdown formats in a few days.

As for how the syntax highlighting works, we use https://github.com/tmm1/pygments.rb, so any changes can be requested there.

@bkeepers bkeepers closed this
@jamiehannaford

@bkeepers How about gh-pages?

@bkeepers
Owner

@benbalter can you speak to the current status of syntax highlighting on Pages?

@benbalter
Owner

Pages uses Pygments as well (and soon Rouge). It appears you can pass options directly to pygments via the {% highlight %} tag, in this case {% highlight php startinline %}, although I've never tried that before (despite my strong PHP roots). :smile:

@parkr (Jekyll Maintainer) may be able to shed some more light.

@parkr

As long as startinline is a valid option in pygments, Jekyll will parse {% highlight php startinline %} to use the php lexer with the options { 'startinline' => true }. We just pass the options on to pygments.rb!

@colinmollenhour

It would be great if the Pages supported the @```php@ syntax with the startinline option true by default so that github pages could be edited/previewd via the github web-based editor which doesn't recognize the Liquid syntax at all. Also it is much shorter to type.

@kirkbushell

Not sure why this doesn't apply everywhere? Isn't working on the readme.md that we setup for our projects.

@polybuildr

This still doesn't seem to work for GitHub gists. Will this be fixed anytime soon?

@svolence

I also encountered this problem, these days has been to consult the relevant materials that I tired like a dog, especially English very poor circumstances, until now I know the problem originally has always been there, ```php code can highlight it in my local, GitHub above is not

@bkeepers
Owner

This should be working properly on Gist. Post examples here if it is not.

https://gist.github.com/spicycode/9352f01ff026d50df4e4

@polybuildr

@bkeepers, if my understanding of the issue is correct, then both the following gists should have been highlighted the same way.

https://gist.github.com/polybuildr/69a42db2cca07a14f805
https://gist.github.com/polybuildr/b79ab80bb453a6232c29

@polybuildr

@bkeepers, could you please take a look at the examples I posted above and let me know if this is a problem at my end or GitHub's.

@bkeepers
Owner

@polybuildr those look ok to me. @aroben or @spicycode, any ideas?

@aroben
Owner

We should probably highlight https://gist.github.com/polybuildr/69a42db2cca07a14f805 even though there's no <?php tag. @vmg fixed this for github.com (at least for inline code in markdown; not sure about full files). Maybe we need to port the fix to Gist.

@spicycode
Owner

The examples should be rendering correctly now on Gist.

@polybuildr

@spicycode, @bkeepers, thanks, fixed now. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.