Skip to content

Commit

Permalink
Stop dropping the last line of code when adding line numbers and file…
Browse files Browse the repository at this point in the history
… doesn't have a concluding newline. Fixes #2521
  • Loading branch information
tabatkins committed Apr 28, 2023
1 parent 7a0241e commit 88f255e
Show file tree
Hide file tree
Showing 4 changed files with 496 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bikeshed/highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def addLineWrappers(doc: t.SpecT, el: t.ElementT, options: LineNumberOptions) ->
else:
h.appendChild(lineWrapper, node)
break
if len(lineWrapper) > 0:
if not h.isEmpty(lineWrapper):
h.appendChild(el, h.E.span({"class": "line-no"}))
h.appendChild(el, lineWrapper)
# Number the lines
Expand Down
16 changes: 16 additions & 0 deletions tests/include006.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<pre class=metadata>
Title: Foo
Group: test
Shortname: foo
Level: 1
Status: LS
ED: http://example.com/foo
Abstract: Verifying all lines are wrapped when numbered, even when the include file lacks a final newline.
Editor: Example Editor
Date: 1970-01-01
</pre>

<pre class=include-code>
path: include006.txt
line-numbers: on
</pre>
Loading

0 comments on commit 88f255e

Please sign in to comment.