Skip to content

Commit

Permalink
Add cell-id anchor for cell identification
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski authored and Carreau committed Feb 20, 2023
1 parent b1a9d6e commit 7bf3fb8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions share/templates/base/cell_id_anchor.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{%- macro cell_id_anchor(cell) -%}
{% if cell.id | length > 0 -%}
id="{{ ('cell-id=' ~ cell.id) | escape_html -}}"
{%- endif %}
{%- endmacro %}
5 changes: 3 additions & 2 deletions share/templates/classic/base.html.j2
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{%- extends 'display_priority.j2' -%}
{% from 'celltags.j2' import celltags %}
{% from 'cell_id_anchor.j2' import cell_id_anchor %}

{% block codecell %}
<div class="cell border-box-sizing code_cell rendered{{ celltags(cell) }}">
<div {{ cell_id_anchor(cell) }} class="cell border-box-sizing code_cell rendered{{ celltags(cell) }}">
{{ super() }}
</div>
{%- endblock codecell %}
Expand Down Expand Up @@ -75,7 +76,7 @@
{% endblock output %}

{% block markdowncell scoped %}
<div class="cell border-box-sizing text_cell rendered{{ celltags(cell) }}">
<div {{ cell_id_anchor(cell) }} class="cell border-box-sizing text_cell rendered{{ celltags(cell) }}">
{%- if resources.global_content_filter.include_input_prompt-%}
{{ self.empty_in_prompt() }}
{%- endif -%}
Expand Down
5 changes: 3 additions & 2 deletions share/templates/lab/base.html.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{%- extends 'display_priority.j2' -%}
{% from 'celltags.j2' import celltags %}
{% from 'cell_id_anchor.j2' import cell_id_anchor %}

{% block codecell %}
{%- if not cell.outputs -%}
Expand All @@ -8,7 +9,7 @@
{%- if not resources.global_content_filter.include_input -%}
{%- set no_input_class="jp-mod-noInput" -%}
{%- endif -%}
<div class="jp-Cell jp-CodeCell jp-Notebook-cell {{ no_output_class }} {{ no_input_class }} {{ celltags(cell) }}">
<div {{ cell_id_anchor(cell) }} class="jp-Cell jp-CodeCell jp-Notebook-cell {{ no_output_class }} {{ no_input_class }} {{ celltags(cell) }}">
{{ super() }}
</div>
{%- endblock codecell %}
Expand Down Expand Up @@ -93,7 +94,7 @@
{% endblock output %}

{% block markdowncell scoped %}
<div class="jp-Cell jp-MarkdownCell jp-Notebook-cell">
<div {{ cell_id_anchor(cell) }} class="jp-Cell jp-MarkdownCell jp-Notebook-cell">
<div class="jp-Cell-inputWrapper">
<div class="jp-Collapser jp-InputCollapser jp-Cell-inputCollapser">
</div>
Expand Down

0 comments on commit 7bf3fb8

Please sign in to comment.