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

add support lang specified in code block #15

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@unibr
Contributor

unibr commented Aug 28, 2012

  • add support lang specified in code block: "~~~ ruby"
  • add enable/disable coderay: option :enable_coderay, which is
    convenient if not want to use coderay
  • add support GitHub flavored code block: "```"
add support lang specified in code block
+ add support lang specified in code block: "~~~ ruby"
+ add enable/disable coderay: option :enable_coderay, which is
convenient if not want to use coderay
+ add support GitHub flavored code block: "```"

change line endings to unix style

seems Git for Windows does not recognize %HOME% in Windows...
@gettalong

This comment has been minimized.

Owner

gettalong commented Aug 29, 2012

Thanks for the pull request!

Before I can pull:

  • Please split your pull request into several ones, each containing just one feature
  • Basic documentation in doc/syntax.page and doc/quickref.page for the github style fenced code block is missing
  • The new option is not included in the documentation for the HTML converter
@unibr

This comment has been minimized.

Contributor

unibr commented Aug 29, 2012

Sorry to mix coderay option here.

For lang specifying and another style of fenced code block, it is better to bundle them, since they need the same place revision.

I will revise the doc accordingly then.

unibr added some commits Aug 30, 2012

remove option :enable_coderay, add doc
+ remove option `:enable_coderay` from previous commit
+ add doc for code block with lang support without IAL
+ add one test. the test can pass **without** coderay
add test case option for future
+ add option `:enable_coderay: false` in test cases for future usage
@cup

This comment has been minimized.

cup commented Aug 30, 2012

Um no. Language for code block is already supported via

{:lang="c"}
    int main(void) {
      printf("Hello world!");
      return 0; 
    }

or

{:lang="c"}
~~~
int main(void) {
  printf("Hello world!");
  return 0; 
}
~~~

http://jason.the-graham.com/2010/11/21/kramdown_support_for_jekyll

@unibr

This comment has been minimized.

Contributor

unibr commented Aug 30, 2012

Indeed. But lang specified in the starting line of the fenced block is much more natural and simpler.

@gettalong

This comment has been minimized.

Owner

gettalong commented Aug 30, 2012

Fenced code blocks with an optional language name are also supported by redcarpet as well as python-markdown. I think of it as a shortcut, like with the header IDs. So +1 from me.

As for the inclusion of another code block fence style: this may not really be necessary since the only other player using this is Github itself and nobody else... And if you look at the latest redcarpet release that is also used by Github Flavored Markdown, you willl find the following:

  • Hard line breaks seem to be enabled in comments like this one but not for README files...
  • Using php-markdown-extra style fenced code blocks (as implemented in kramdown) works perfectly on Github (because redcarpet implements it), even using the language name for the syntax highlighting
@unibr

This comment has been minimized.

Contributor

unibr commented Aug 30, 2012

Have a try using ~~~:

~~~ ruby
lang = :ruby
str = "abc"
~~~

becomes:

lang = :ruby
str = "abc"

Exactly... GitHub does support php style. I was cheated by the so called GitHub Flavored Markdown. In fact, I hate ```. ~~~ is much better.

@ghost ghost assigned gettalong Sep 12, 2012

@gettalong

This comment has been minimized.

Owner

gettalong commented Sep 12, 2012

I have implemented support for specifying the language on the starting line of a fenced code block based on your patch. However, I did a squashed merge with additional corrections because the commits in this pull request do not all apply to this problem.

@gettalong gettalong closed this Sep 12, 2012

@cup

This comment has been minimized.

cup commented Sep 17, 2012

@gettalong The new style is all well and good, but as far as I can tell the old style as mentioned above by me is now broken on kramdown 0.14.0

@gettalong

This comment has been minimized.

Owner

gettalong commented Sep 18, 2012

Could you provide a test case? What exactly is broken? Please note that in addition to allowing the code language name to be specified on the starting line of a fenced code block, the syntax for specifying the code language via an IAL has also changed, ie. you have to use {:.language-ruby} instead of {: lang='ruby'} now

@cup

This comment has been minimized.

cup commented Sep 18, 2012

Can you elaborate as to why the IAL syntax has changed? I am trying to use kramdown 0.14.0 with coderay 1.0.7

@gettalong

This comment has been minimized.

Owner

gettalong commented Sep 18, 2012

Please have a look at the discussion on the kramdown-users mailing list (http://rubyforge.org/pipermail/kramdown-users/2012-August/thread.html and http://rubyforge.org/pipermail/kramdown-users/2012-September/thread.html; the topic is "Syntax for specifying code highlighting language | Github flavored code blocks style").

The gist is that the lang="" is used by HTML to specify natural languages and not code languages.

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