middleman / middleman-syntax

Code syntax highlighting plugin via Rouge for Middleman
https://middlemanapp.com
MIT License
179 stars 57 forks source link

PHP code block without `<?php` #55

Closed jorilallo closed 8 years ago

jorilallo commented 8 years ago

Is there a way to highlight PHP codeblocks without having <?php at the beginning of the file? I'm using code ERB function. At least GitHub's code blocks allow this behaviour and it's pretty useful for tutorials when not listing a full php file.

bhollis commented 8 years ago

I think this is a question for https://github.com/jneen/rouge - this plugin simply ties Rouge into Middleman.

jorilallo commented 8 years ago

Fair enough, thanks @bhollis

realityking commented 8 years ago

Rouge does support ignoring the opening tags, but it's a setting on the lexer: https://github.com/jneen/rouge/blob/76647eb9e297de11ba3b174a45f1ae1ed4a34f8e/lib/rouge/lexers/php.rb#L21

Unfortunately I haven't been able to figure out how to set that trough middleman-syntax. Any advice @bhollis ?

philsturgeon commented 8 years ago

Hey @bhollis, I'd also be interested in what @realityking is trying to do. I'd rather not have to put <?php at the start of every code example as a lot of the time that's not actually valid for the code im trying to display.

How can I pass the start_inline option to the lexer? I tried:

activate :syntax, wrap: true, lexer_options: { php: { start_inline: true} }

Didn't work 💨

realityking commented 8 years ago

Yeah I got exactly that far and then gave up 😞

bhollis commented 8 years ago

https://github.com/middleman/middleman-syntax/blob/master/lib/middleman-syntax/extension.rb#L15 makes it look like this should work. Have you tried this:

activate :syntax, wrap: true, lexer_options: { start_inline: true }

If that doesn't work, what would really help would be a PR to add a failing test case for this situation to this repo.

graygilmore commented 8 years ago

If you're using fenced code blocks you can use:

```php?start_inline=1

I haven't been able to get the lexer_options to work yet.