ghostium
ghostium copied to clipboard
Add prism line-numbers & line-highlight functionality
It would be nice to add line numbers & line highlight for code highlighting.
You can add this yourself by editing src/default.hbs
and running grunt build, I wouldn't say these come under a sensible default.
Thanks. This I figured out already. What I'm missing is how to tell ghostium via the Markdown which lines to hightlight and to put lines numbers. Do you have any suggestions, Steve?
I expect you can't do it in markdown, and have to put the <pre>
tag in yourself, not sure though.
... I hope now you realise why I create this request for improvement.
I don't think there's any improvement to be made, these Prism plugins don't make for a sensible default (and they're easy to add anyway), and themes have no control over Ghost's Markdown implementation, which supports adding classes to code blocks, and nothing more, certainly not data attributes.
Thanks for sharing your thoughts, Steve. Can you provide some arguments to support you point as to how easy it is to add these non sensible defaults?
Add the additional plugins here into default.hbs#L112, they should have already been installed by Bower
Run grunt dryrun
to compile
I got this part, what about turning line numbers on and highlighting rows?
I'm not sure which part you're not understanding, Steve showed you how to add the line-numbers and line-highlight plugins to the theme. To get them actually working you'll need to add the 'line-numbers' class and 'data-line' attribute to the
block. You'd need to modify ghosts markdown engine to get them enabled via markdown. On 14/07/2014 5:54 am, "Ivan Hristov" [email protected] wrote:I got this part, what about turning line numbers on and highlighting rows?
— Reply to this email directly or view it on GitHub https://github.com/oswaldoacauan/ghostium/issues/109#issuecomment-48850383 .
The question is not about just adding line-numbers and line-highlighting prismJS plugins to the theme. The suggestion is about adding functionality which allows you to highlight lines. So from your response I got it's not so simple as Steve suggests. Thanks for your comment.
I think you've missed that Markdown allows you to embed HTML, what I was saying you could do is this:
Instead of:
# A heading
Some text
'''language-javascript
alert('hi!');
'''
Some more text
You can do:
# A heading
Some text
<pre><code class="language-javascript" data-line="15-25">
alert('hi!');
</code></pre>
Some more text
Ah, Steve, thank you very much! I'm going to try this shortly.
Sorry for replying an old thread.
There is a problem with this approach (using <pre><code>
) when your code contains a <
or >
. The only way to make it work is by replacing them with <
or >
which is not so convenient.