Skip to content

Conversation

@openorclose
Copy link
Contributor

What is the purpose of this pull request? (put "X" next to an item, remove the rest)

• [X] Enhancement to an existing feature

Fixes #1114

What is the rationale for this request?

Authors may want to include a code snippet from a larger file, so they may prefer to have the original line numbers.

What changes did you make? (Give an overview)
If the start-from attribute it set, add an inline style that sets the counter to the specified value -1.

Provide some example code that this change will affect:

function add(a, b) {
    return a + b;
}

Outcome:
image

Is there anything you'd like reviewers to focus on?

How should this interact with line highlighting? I didn't change that part, so line highlighting still always starts from line 1.

Should we make line highlighting follow the start-from attribute too?

Testing instructions:

Proposed commit message: (wrap lines at 72 characters)

Add start from line number functionality to code blocks

Let's do this by checking for the `start-from` attribute on a code block
and then set an inline style that sets the `line` counter to the 
appropriate value.

@damithc
Copy link
Contributor

damithc commented Mar 11, 2020

Nice.

Should we make line highlighting follow the start-from attribute too?

Feels like we should as I think authors will look at the live preview to figure out which lines to highlight.

Copy link
Contributor

@alyip98 alyip98 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@openorclose openorclose requested a review from marvinchin March 21, 2020 10:32
Copy link
Contributor

@marvinchin marvinchin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@marvinchin marvinchin added this to the v2.12.1 milestone Mar 23, 2020
@marvinchin marvinchin merged commit 409e90c into MarkBind:master Mar 23, 2020
Tejas2805 added a commit to Tejas2805/markbind that referenced this pull request Mar 23, 2020
* 'master' of https://github.com/MarkBind/markbind:
  Update test files (MarkBind#1138)
  Remove OK button from modals (MarkBind#1134)
  Add start from line number functionality to code blocks (MarkBind#1115)
  Allow special tags to be self-closing (MarkBind#1101)
  Simplify baseUrl resolving process (MarkBind#1087)
  Remove redundant file writing (MarkBind#1090)
  Bump acorn from 5.7.3 to 5.7.4 (MarkBind#1121)
  Bump acorn from 7.1.0 to 7.1.1 in /src/lib/markbind (MarkBind#1120)
  Unify markdown-it parser variants (MarkBind#1056)
  Remove dynamic include feature (MarkBind#1037)
  Fix flex shrink not applying in content wrapper (MarkBind#1135)
  Escape Nunjucks for special tags (MarkBind#1049)
  Update documentation on icon slot for boxes (MarkBind#1123)
Tejas2805 added a commit to Tejas2805/markbind that referenced this pull request Mar 23, 2020
…x-pageNav

* 'master' of https://github.com/MarkBind/markbind:
  Update test files (MarkBind#1138)
  Remove OK button from modals (MarkBind#1134)
  Add start from line number functionality to code blocks (MarkBind#1115)
  Allow special tags to be self-closing (MarkBind#1101)
  Simplify baseUrl resolving process (MarkBind#1087)
  Remove redundant file writing (MarkBind#1090)
  Bump acorn from 5.7.3 to 5.7.4 (MarkBind#1121)
  Bump acorn from 7.1.0 to 7.1.1 in /src/lib/markbind (MarkBind#1120)
  Unify markdown-it parser variants (MarkBind#1056)
  Remove dynamic include feature (MarkBind#1037)
  Fix flex shrink not applying in content wrapper (MarkBind#1135)
  Escape Nunjucks for special tags (MarkBind#1049)
  Update documentation on icon slot for boxes (MarkBind#1123)
  Convert code in boxes to code block (MarkBind#1086)
@damithc
Copy link
Contributor

damithc commented Mar 31, 2020

This feature in action https://nus-te3201.github.io/2020/schedule/week11/topics-py.html
Good work @openorclose and reviewers

marvinchin pushed a commit that referenced this pull request Apr 10, 2020
Let's do this by checking for the `start-from` attribute on a code block
and then set an inline style that sets the `line` counter to the 
appropriate value.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code blocks: support specifying a starting line number

4 participants