Skip to content

Add EXTENSION_INLINE_CODE_LANG - #262

Open
emilkm wants to merge 1 commit into
russross:masterfrom
emilkm:extension_inline_code_lang
Open

emilkm wants to merge 1 commit into
russross:masterfrom
emilkm:extension_inline_code_lang

Conversation

@emilkm

@emilkm emilkm commented May 4, 2016

Copy link
Copy Markdown

Follow up from #257

Enables syntax highlighting of inline code with JavaScript libraries like prism.js

Adding a language specifier following the backticks in the markdown source

`def foo(): pass`(python)

will render as (with extension enabled)

<code class="language-python">def foo(): pass</code>

and (with extension NOT enabled)

<code>def foo(): pass</code>(python)

Whitespace is allowed between the closing backtick and the language specifier. The following

`def foo(): pass` (python)

will also render to

<code class="language-python">def foo(): pass</code>

@emilkm
emilkm force-pushed the extension_inline_code_lang branch from b4fe228 to 30a3394 Compare May 4, 2016 20:14
Comment thread html.go Outdated
func (options *Html) CodeSpan(out *bytes.Buffer, text []byte) {
out.WriteString("<code>")
func (options *Html) CodeSpan(out *bytes.Buffer, text []byte, lang string) {
if len(lang) > 0 {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's more idiomatic to check that a string is not empty by doing if lang != "" {.

@dmitshur

dmitshur commented May 4, 2016

Copy link
Copy Markdown
Collaborator

I left some inline Go style comments for your reference. However, this PR should first be reviewed (and accepted) at a high level, so you can put off making those changes until later if you wish. I just wanted to post them since they're general Go code review comments.

@emilkm
emilkm force-pushed the extension_inline_code_lang branch from 30a3394 to c32c24a Compare May 4, 2016 21:08
Enables prettier syntax highlighting of inline code with JavaScript libraries like prism.js

Adding a language specifier following the backticks in the markdown source

    `def foo(): pass`(python)

will render as (with extension enabled)

    <code class="langueage-python">def foo(): pass</code>

and (with extension NOT enabled)

    <code>def foo(): pass</code>(python)

Whitespace is allowed between the closing backtick and the language specifier. The following

    `def foo(): pass` (python)

will also render to

    <code class="langueage-python">def foo(): pass</code>
@emilkm
emilkm force-pushed the extension_inline_code_lang branch from c32c24a to 724433a Compare May 4, 2016 21:13
@emilkm

emilkm commented May 4, 2016

Copy link
Copy Markdown
Author

Thanks for the comments. I have done the changes.

I agree the change to Render interface should not be taken lightly.

@rtfb

rtfb commented Aug 10, 2016

Copy link
Copy Markdown
Collaborator

Please see discussion at #288, I'd like to postpone taking PRs like this.

@emilkm

emilkm commented Aug 10, 2016

Copy link
Copy Markdown
Author

No problem.

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

Successfully merging this pull request may close these issues.

3 participants