Skip to content

Commit

Permalink
feat(syntax): add support for highlighting lines in code snippets
Browse files Browse the repository at this point in the history
fix #520
  • Loading branch information
talha131 committed Feb 2, 2020
1 parent 3a34a3e commit ba2de8c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
39 changes: 39 additions & 0 deletions documentation/content/Components/code-style-highlight-lines.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
Title: Code Snippets -- Highlight Lines
Tags: markdown, code-snippets, gist
Date: 2020-02-02 20:12
comments: false
Slug: code-snippets-highlight-lines
authors: Talha Mansoor
Category: Components
---

[Python-Markdown](https://github.com/Python-Markdown/markdown/) uses
[CodeHilite](https://python-markdown.github.io/extensions/code_hilite/) <!-- yaspeller ignore -->
extension for syntax highlighting.

This extension lets you highlight specific lines in your code snippets. You can read the instructions [here](https://python-markdown.github.io/extensions/code_hilite/#colons).

Elegant supports this feature.

:::python hl_lines="1 3"
# This line is emphasized
# This line isn't
# This line is emphasized

Another example,

:::html hl_lines="2"
<div
class="photoswipe-gallery"
itemscope
itemtype="http://schema.org/ImageGallery"
>
</div>

Another example,

#!python hl_lines="2"
# Code goes here ..
# This line is emphasized
# This line isn't
6 changes: 6 additions & 0 deletions static/css/code.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/* For highlighting lines in code snippets */
.highlight span.hll span {
background-color: black;
display: inline-block;
width: 100%;
}
div.highlight {
margin-bottom: 20px;
border-radius: var(--borderRadius);
Expand Down
7 changes: 4 additions & 3 deletions static/css/pygments.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.highlight .hll {
background-color: #ffffcc;
/* This line results in highlighting whitespaces -- Talha */
/* background-color: #ffffcc; */
}
.highlight {
background: #282828;
Expand Down Expand Up @@ -301,8 +302,8 @@
color: #d3869b;
background-color: #282828;
} /* Literal.Number.Integer.Long */
/* My fixes */
/* My fixes -- Talha*/
.highlight .cpf {
color: #b8bb26;
background-color: #282828;
}
}

0 comments on commit ba2de8c

Please sign in to comment.