diff --git a/CHANGES.txt b/CHANGES.txt index 5038cfccdb..58da90e87d 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -7,6 +7,9 @@ Features Bugfixes -------- +* Default to no line numbers in code blocks, honor CodeHilite + requesting no line numbers. Listing pages still use line numbers + (Issue #3426) * Remove duplicate MathJax config in bootstrap themes (Issue #3427) * Fix ``doit`` requirement to ``doit>=0.32.0`` (Issue #3422) diff --git a/nikola/plugins/task/listings.py b/nikola/plugins/task/listings.py index 902cc96bfb..7fa919d902 100644 --- a/nikola/plugins/task/listings.py +++ b/nikola/plugins/task/listings.py @@ -134,7 +134,9 @@ def render_listing(in_name, out_name, input_folder, output_folder, folders=[], f except Exception: lexer = TextLexer() fd.seek(0) - code = highlight(fd.read(), lexer, utils.NikolaPygmentsHTML(in_name)) + code = highlight( + fd.read(), lexer, + utils.NikolaPygmentsHTML(in_name, linenos='table')) title = os.path.basename(in_name) else: code = '' diff --git a/nikola/utils.py b/nikola/utils.py index a4d631da6a..78c50e942b 100644 --- a/nikola/utils.py +++ b/nikola/utils.py @@ -1629,7 +1629,11 @@ def __init__(self, anchor_ref=None, classes=None, **kwargs): anchor_ref, lang=LocaleBorg().current_lang, force=True) self.nclasses = classes kwargs['cssclass'] = 'code' + if not kwargs.get('linenos'): + # Default to no line numbers (Issue #3426) + kwargs['linenos'] = False if kwargs.get('linenos') not in {'table', 'inline', 'ol', False}: + # Map invalid values to table kwargs['linenos'] = 'table' kwargs['anchorlinenos'] = kwargs['linenos'] == 'table' kwargs['nowrap'] = False