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

chore: Replace markup_txt with rfc2html #6632

Merged
merged 14 commits into from
Jan 5, 2024
16 changes: 10 additions & 6 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@
from django import forms
from django.contrib.staticfiles import finders

import rfc2html

import debug # pyflakes:ignore

from ietf.doc.models import ( Document, DocHistory, DocEvent, BallotDocEvent, BallotType,
Expand Down Expand Up @@ -80,7 +82,7 @@
from ietf.review.models import ReviewAssignment
from ietf.review.utils import can_request_review_of_doc, review_assignments_to_list_for_docs, review_requests_to_list_for_docs
from ietf.review.utils import no_review_from_teams_on_doc
from ietf.utils import markup_txt, log, markdown
from ietf.utils import log, markdown
from ietf.utils.draft import PlaintextDraft
from ietf.utils.response import permission_denied
from ietf.utils.text import maybe_split
Expand Down Expand Up @@ -264,7 +266,9 @@ def document_main(request, name, rev=None, document_html=False):

file_urls, found_types = build_file_urls(doc)
content = doc.text_or_error() # pyflakes:ignore
content = markup_txt.markup(maybe_split(content, split=split_content))
content = maybe_split(content, split=split_content)
if content:
content = rfc2html.markup(content)

if not found_types:
content = "This RFC is not currently available online."
Expand Down Expand Up @@ -400,7 +404,9 @@ def document_main(request, name, rev=None, document_html=False):

file_urls, found_types = build_file_urls(doc)
content = doc.text_or_error() # pyflakes:ignore
content = markup_txt.markup(maybe_split(content, split=split_content))
content = maybe_split(content, split=split_content)
if content:
content = rfc2html.markup(content)

latest_revision = doc.latest_event(NewRevisionDocEvent, type="new_revision")

Expand Down Expand Up @@ -775,7 +781,7 @@ def document_main(request, name, rev=None, document_html=False):
content = "A conflict review response has not yet been proposed."
else:
content = doc.text_or_error() # pyflakes:ignore
content = markup_txt.markup(content)
content = markdown.markdown(content)

ballot_summary = None
if doc.get_state_slug() in ("iesgeval", ) and doc.active_ballot():
Expand Down Expand Up @@ -890,8 +896,6 @@ def document_main(request, name, rev=None, document_html=False):
basename = "{}.txt".format(doc.name)
pathname = os.path.join(doc.get_file_path(), basename)
content = get_unicode_document_content(basename, pathname)
# If we want to go back to using markup_txt.markup_unicode, call it explicitly here like this:
# content = markup_txt.markup_unicode(content, split=False, width=80)

assignments = ReviewAssignment.objects.filter(review__name=doc.name)
review_assignment = assignments.first()
Expand Down
17 changes: 13 additions & 4 deletions ietf/templates/doc/document_draft.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
<meta name="description"
content="{{ doc.title }} {% if doc.type_id == 'rfc' and not snapshot %}(RFC {{ rfc_number }}{% if published %}, {{ doc.pub_date|date:'F Y' }}{% endif %}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %}){% endif %}">
{% endblock %}
{% block morecss %}.inline { display: inline; }{% endblock %}
{% block morecss %}
.rfcmarkup :is(h1, h2, h3, h4, h5, h6),
.rfcmarkup :is(.h1, .h2, .h3, .h4, .h5, .h6) {
font-weight: bold;
font-size: 1em;
}
.rfcmarkup .newpage { margin-top: -1.5em; }
.rfcmarkup .grey, hr { opacity: .25; }
{% endblock %}
{% block title %}
{% if doc.type_id == "rfc" and not snapshot %}
RFC {{ rfc_number }} - {{ doc.title }}
Expand Down Expand Up @@ -658,7 +666,7 @@
</i>
Nits
</a>
<div class="dropdown inline">
<div class="dropdown d-inline">
<button class="btn btn-primary btn-sm dropdown-toggle"
type="button"
id="ddSearchMenu"
Expand Down Expand Up @@ -760,8 +768,9 @@
{{ name }}-{{ doc.rev }}
{% endif %}
</div>
<div class="card-body">
<pre>{{ content|sanitize|safe|default:"(Unavailable)" }}</pre>
<div class="card-body rfcmarkup">
<!-- [html-validate-disable-block attr-quotes, void-style, element-permitted-content, heading-level, no-dup-id, valid-id -- FIXME: rfcmarkup/rfc2html generates HTML with issues] -->
{{ content|safe|default:"(Unavailable)" }}
</div>
</div>
{% if split_content %}
Expand Down
4 changes: 2 additions & 2 deletions ietf/templates/doc/document_html.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
{% else %}
<div class="rfcmarkup">
<br class="noprint">
<!-- [html-validate-disable-block attr-quotes, void-style, element-permitted-content, heading-level -- FIXME: rfcmarkup/rfc2html generates HTML with issues] -->
<!-- [html-validate-disable-block attr-quotes, void-style, element-permitted-content, heading-level, no-dup-id, valid-id -- FIXME: rfcmarkup/rfc2html generates HTML with issues] -->
{{ doc.htmlized|default:"Generation of htmlized text failed"|safe }}
</div>
{% endif %}
Expand Down Expand Up @@ -332,4 +332,4 @@
</div>
{% analytical_body_bottom %}
</body>
</html>
</html>
17 changes: 13 additions & 4 deletions ietf/templates/doc/document_rfc.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
<meta name="description"
content="{{ doc.title }} (RFC {{ doc.rfc_number }}, {{ doc.pub_date|date:'F Y' }}{% if obsoleted_by %}; obsoleted by {% for rel in obsoleted_by %}{{ rel.source.name|prettystdname}}{% if not forloop.last%}, {% endif %}{% endfor %}{% endif %})">
{% endblock %}
{% block morecss %}.inline { display: inline; }{% endblock %}
{% block morecss %}
.rfcmarkup :is(h1, h2, h3, h4, h5, h6),
.rfcmarkup :is(.h1, .h2, .h3, .h4, .h5, .h6) {
font-weight: bold;
font-size: 1em;
}
.rfcmarkup .newpage { margin-top: -1.5em; }
.rfcmarkup .grey, hr { opacity: .25; }
{% endblock %}
{% block title %}
RFC {{ doc.rfc_number }} - {{ doc.title }}
{% endblock %}
Expand Down Expand Up @@ -155,8 +163,9 @@
<div class="card-header">
RFC {{ doc.rfc_number }}
</div>
<div class="card-body">
<pre>{{ content|sanitize|safe|default:"(Unavailable)" }}</pre>
<div class="card-body rfcmarkup">
<!-- [html-validate-disable-block attr-quotes, void-style, element-permitted-content, heading-level, no-dup-id, valid-id -- FIXME: rfcmarkup/rfc2html generates HTML with issues] -->
{{ content|safe|default:"(Unavailable)" }}
</div>
</div>
{% if split_content %}
Expand All @@ -173,4 +182,4 @@
</script>
<script src="{% static 'ietf/js/document_timeline.js' %}">
</script>
{% endblock %}
{% endblock %}
69 changes: 0 additions & 69 deletions ietf/utils/markup_txt.py

This file was deleted.

1 change: 1 addition & 0 deletions ietf/utils/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def vnu_filter_message(msg, filter_db_issues, filter_test_issues):
if filter_test_issues and re.search(
r"""Ceci\ n'est\ pas\ une\ URL|
^The\ '\w+'\ attribute\ on\ the\ '\w+'\ element\ is\ obsolete|
^Duplicate\ ID|^The\ first\ occurrence\ of\ ID|
^Section\ lacks\ heading""",
msg["message"],
flags=re.VERBOSE,
Expand Down
Loading