inline php #107

Closed
akzhan opened this Issue Apr 9, 2012 · 40 comments

Comments

Projects
None yet

akzhan commented Apr 9, 2012

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- commented Sep 22, 2012

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- commented Oct 25, 2012

Issue can be closed

Topener commented Jun 6, 2013

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

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

Dayjo commented Jun 14, 2013

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.

+1 from me for setting startinline option to true

@gjtorikian gjtorikian closed this Sep 24, 2013

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.

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

Topener commented Oct 10, 2013

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

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

@gjtorikian gjtorikian reopened this Oct 15, 2013

Member

gjtorikian commented Oct 15, 2013

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

Dayjo commented Oct 15, 2013

Also happy to double vote up! 👍

Topener commented Oct 18, 2013

good thing we are open again.

nickl- commented Oct 21, 2013

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

#158-11622364

=)

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

scottux commented Nov 21, 2013

👍

pnm1231 commented Dec 18, 2013

Is this getting fixed any soon?

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

Member

bkeepers commented Jan 28, 2014

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 Jan 28, 2014

@bkeepers How about gh-pages?

Member

bkeepers commented Feb 17, 2014

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

Member

benbalter commented Feb 17, 2014

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). 😄

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

parkr commented Feb 17, 2014

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!

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.

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

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

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

Member

bkeepers commented Nov 21, 2014

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

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

@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

@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.

Member

bkeepers commented Dec 1, 2014

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

aroben commented Dec 1, 2014

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.

Member

spicycode commented Dec 2, 2014

The examples should be rendering correctly now on Gist.

Member

bkeepers commented Dec 2, 2014

❤️ @spicycode

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

There is no syntax highlight for .php files.

It does seem like there's been a regression. The same two gists I posted before have the same issue as before: the one with the <?php gets highlighted, the other doesn't.

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

@spicycode can someone reopen this issue then?

Definitely still seeing a problem with the gists which no longer syntax highlight PHP without the opening PHP tag. It's common to use gists to share part of a file rather than the whole file, so this feature should probably be reinstated. I think this is a current bug and the issue should be open

The issue looks like it needs to be reopened, indeed. Example https://gist.github.com/polybuildr/69a42db2cca07a14f805 of @polybuildr still does not work.

@3Dgoo 3Dgoo referenced this issue in plastyk/silverstripe-dashboard Jul 4, 2017

Closed

Documentation php code highlighting #83

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment