Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Support syntax highlighting in code blocks #67

Closed
frankiejarrett opened this issue Jan 3, 2015 · 8 comments · Fixed by #68
Closed

Support syntax highlighting in code blocks #67

frankiejarrett opened this issue Jan 3, 2015 · 8 comments · Fixed by #68
Assignees

Comments

@frankiejarrett
Copy link
Contributor

AFAIK the only way to achieve a code block in readme.txt is to use the <pre> tag.

It would be nice to add support for a lang attribute so that syntax highlighting can be added when converting to markdown.

TXT

<pre lang="php">
function foo() {
    $bar = 'baz';
}
</pre>

Markdown

function foo() {
    $bar = 'baz';
}
@kucrut
Copy link

kucrut commented Jan 3, 2015

Hmm, you can already use backticks:

`
code...
`

@frankiejarrett
Copy link
Contributor Author

Oh wow. To my surprise this already works! 😄

By doing: <pre lang="php">

screen shot 2015-01-03 at 11 39 18 am

screen shot 2015-01-03 at 11 39 38 am

@frankiejarrett
Copy link
Contributor Author

@kucrut That's what I thought too, but single backticks used to create code blocks were breaking the page when used in the FAQ tab on my WordPress.org plugin. Using them for inline code seems to work fine.

@frankiejarrett
Copy link
Contributor Author

I'm going to reopen this because I do think there is some slight room for improvement.

It would be cleaner if <pre lang="php"> converted to ```php in markdown.

@frankiejarrett frankiejarrett reopened this Jan 3, 2015
@westonruter
Copy link
Contributor

So <pre lang="php"> is part of the WP readme.txt “standard”? I don't see it mentioned on https://wordpress.org/plugins/about/readme.txt

Is it a hidden feature?

@frankiejarrett
Copy link
Contributor Author

@westonruter Not sure if it's part of the "standard", but it does seem to work.

https://wordpress.org/plugins/prevent-concurrent-logins/faq/

@westonruter
Copy link
Contributor

That's great. I was wondering how we could implement that.

@westonruter
Copy link
Contributor

@fjarrett let me know how #68 works for you.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants