Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: Add Line Number Configuration via HTML Attributes #2

Open
taufik-nurrohman opened this issue Jun 5, 2020 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@taufik-nurrohman
Copy link
Owner

What I am thinking:

  • data-ln-active → Determine line or range of line to be highlighted.
  • data-ln-hide → Hide line number only for this block.
  • data-ln-start → Determine the start number (default to 1).
@taufik-nurrohman taufik-nurrohman added the enhancement New feature or request label Jun 5, 2020
@taufik-nurrohman
Copy link
Owner Author

taufik-nurrohman commented Jun 5, 2020

Or just create a parser that can convert this kind of attribute value into object:

<code data-ln="active:4-12;hide:0;start:2;">

@taufik-nurrohman
Copy link
Owner Author

taufik-nurrohman commented Jun 5, 2020

Possible value for active setting:

  • Line number, e.g. active:4
  • Line numbers, e.g. active:4,6,8
  • Range number, e.g. active:4-8
  • Range numbers, e.g. active:4-8,16-30

@taufik-nurrohman
Copy link
Owner Author

taufik-nurrohman commented Jun 6, 2020

Nowdays, web browsers are smart enough to read linear-gradient() and calc() function in CSS. I would go with that!

Instead of splitting the code block line-by-line and then rebuild them into a <table> element (that is placed inside a <pre> tag 🤦🏻‍♂️), I would simply add more background images to the current block element using CSS gradients:

<pre><code class ="hljs">function foo() {
  return 'bar';
}

a
a
a
a</code></pre>

<style>
.hljs {
  display: block;
  padding: .5em;
  line-height: 1.2em;
  background-color: #eee;
  background-repeat:
    repeat-x,
    repeat-x;
  background-image:
    linear-gradient(#ddd calc(1.2em * 1), transparent calc(1.2em * 1), transparent),
    linear-gradient(#ddd calc(1.2em * 2), transparent calc(1.2em * 2), transparent);
  background-position:
    0 calc(0.5em + (1.2em * 1)),
    0 calc(0.5em + (1.2em * 5));
}
</style>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant