ghostium icon indicating copy to clipboard operation
ghostium copied to clipboard

Add prism line-numbers & line-highlight functionality

Open ihr opened this issue 10 years ago • 13 comments

It would be nice to add line numbers & line highlight for code highlighting.

ihr avatar Jun 03 '14 20:06 ihr

You can add this yourself by editing src/default.hbs and running grunt build, I wouldn't say these come under a sensible default.

stevelacey avatar Jul 12 '14 11:07 stevelacey

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?

ihr avatar Jul 12 '14 17:07 ihr

I expect you can't do it in markdown, and have to put the <pre> tag in yourself, not sure though.

stevelacey avatar Jul 13 '14 08:07 stevelacey

... I hope now you realise why I create this request for improvement.

ihr avatar Jul 13 '14 18:07 ihr

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.

stevelacey avatar Jul 13 '14 19:07 stevelacey

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?

ihr avatar Jul 13 '14 19:07 ihr

Add the additional plugins here into default.hbs#L112, they should have already been installed by Bower Run grunt dryrun to compile

stevelacey avatar Jul 13 '14 19:07 stevelacey

I got this part, what about turning line numbers on and highlighting rows?

ihr avatar Jul 13 '14 19:07 ihr

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 .

bkbooth avatar Jul 13 '14 20:07 bkbooth

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.

ihr avatar Jul 13 '14 20:07 ihr

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

stevelacey avatar Jul 13 '14 21:07 stevelacey

Ah, Steve, thank you very much! I'm going to try this shortly.

ihr avatar Jul 13 '14 21:07 ihr

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 &lt or &gt which is not so convenient.

yohanesgultom avatar May 26 '16 01:05 yohanesgultom