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

Add cell-id anchor for cell identification #1897

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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