~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
11 3

[PATCH core.sr.ht] Add strikethrough support to SrhtRenderer

Details
Message ID
<20220721021415.40062-1-jack@jpgleeson.com>
DKIM signature
pass
Download raw message
Patch: +7 -2
---
This adds back strikethrough support to the markdown renderer.
Strikethroughs are rendered as del HTML elements.
 srht/markdown.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/srht/markdown.py b/srht/markdown.py
index 5005542..68eae1d 100644
--- a/srht/markdown.py
+++ b/srht/markdown.py
@@ -12,7 +12,7 @@ import mistletoe as m
from mistletoe.span_token import SpanToken, RawText
import re

SRHT_MARKDOWN_VERSION = 14
SRHT_MARKDOWN_VERSION = 15

class PlainLink(SpanToken):
    """
@@ -126,6 +126,11 @@ class SrhtRenderer(m.HTMLRenderer):
        _id = re.sub(r'[^a-z0-9-_]', '', inner.lower().replace(" ", "-"))
        return template.format(level=level, inner=inner, _id=_id)

    def render_strikethrough(self, token):
        template = '<del>{inner}</del>'
        inner = html.escape(token.children[0].content)
        return template.format(inner=inner)

def _img_filter(tag, name, value):
    if name in ["alt", "height", "width"]:
        return True
@@ -181,7 +186,7 @@ _sanitizer = bleach.sanitizer.Cleaner(
        "q",
        "h1", "h2", "h3", "h4", "h5", "h6",
        "details", "summary",
        "abbr", "dfn",
        "abbr", "dfn", "del"
    ],
    attributes={**bleach.sanitizer.ALLOWED_ATTRIBUTES, **_sanitizer_attrs},
    protocols=[
-- 
2.36.1
Details
Message ID
<5b194643-d654-87b6-8e59-67ef0c927637@c9yh.net>
In-Reply-To
<20220721021415.40062-1-jack@jpgleeson.com> (view parent)
DKIM signature
permerror
Download raw message
Hello Jack

On 7/20/2022 9:14 PM, jack gleeson wrote:
> @@ -181,7 +186,7 @@ _sanitizer = bleach.sanitizer.Cleaner(
>           "q",
>           "h1", "h2", "h3", "h4", "h5", "h6",
>           "details", "summary",
> -        "abbr", "dfn",
> +        "abbr", "dfn", "del"
>       ],
>       attributes={**bleach.sanitizer.ALLOWED_ATTRIBUTES, **_sanitizer_attrs},
>       protocols=[


I am fine with the current solution, however I know some markdown 
engines perform strikethroughs with the ~~ symbol. Thoughts?
Details
Message ID
<CLLN7I60N9AV.20TKSU5IUFKZ@taiga>
In-Reply-To
<5b194643-d654-87b6-8e59-67ef0c927637@c9yh.net> (view parent)
DKIM signature
pass
Download raw message
On Thu Jul 21, 2022 at 11:12 PM CEST, Brett Gilio wrote:
> I am fine with the current solution, however I know some markdown 
> engines perform strikethroughs with the ~~ symbol. Thoughts?

We use CommonMark, so it would have to be standardized there first.
Details
Message ID
<f958abbc-3afb-fd47-d254-c7ac0d3d5291@c9yh.net>
In-Reply-To
<CLLN7I60N9AV.20TKSU5IUFKZ@taiga> (view parent)
DKIM signature
permerror
Download raw message
On 7/21/2022 4:13 PM, Drew DeVault wrote:
>
> We use CommonMark, so it would have to be standardized there first.


In that case, I am totally fine with omitting <del> from the sanitizer.
Details
Message ID
<0B9EFR.7GYCELIH57OD1@jpgleeson.com>
In-Reply-To
<f958abbc-3afb-fd47-d254-c7ac0d3d5291@c9yh.net> (view parent)
DKIM signature
pass
Download raw message
This patch works with the ~~ notation and recognises it as 
strikethrough.

Use of <del> in place of <s> was just personal preference, I'm agnostic
on which is more suitable.

I didn't realise CommonMark still hadn't agreed on including
strikethrough in the specification. I see the value in including them,
but recognise that it is not in the standard. In which case, it's fair
to call this out of scope and ddevault can ignore this patch.
Details
Message ID
<59e82aa2-1228-7357-ce8f-f4310debc475@c9yh.net>
In-Reply-To
<0B9EFR.7GYCELIH57OD1@jpgleeson.com> (view parent)
DKIM signature
permerror
Download raw message
On 7/21/2022 6:30 PM, Jack Gleeson wrote:

> This patch works with the ~~ notation and recognises it as strikethrough.
>
> Use of <del> in place of <s> was just personal preference, I'm agnostic
> on which is more suitable.
>
> I didn't realise CommonMark still hadn't agreed on including
> strikethrough in the specification. I see the value in including them,
> but recognise that it is not in the standard. In which case, it's fair
> to call this out of scope and ddevault can ignore this patch.
>
>
>
I'm not seeing where in this patch it is recognizing the ~~ notation. 
Regardless, Drew, would  you be open to not sanitizing <del>?
Details
Message ID
<HN9EFR.1GFJIRNOF2BO2@jpgleeson.com>
In-Reply-To
<59e82aa2-1228-7357-ce8f-f4310debc475@c9yh.net> (view parent)
DKIM signature
pass
Download raw message

>> I'm not seeing where in this patch it is recognizing the ~~ notation.
That's something built in to the mistletoe library.
It also includes support for tables - also not in CommonMark.
I'm just providing a function to render the existing strikethrough 
tokens
as strikethroughs.
Details
Message ID
<a3230811-4f76-a0d1-6b1f-96bab0e96e45@c9yh.net>
In-Reply-To
<HN9EFR.1GFJIRNOF2BO2@jpgleeson.com> (view parent)
DKIM signature
permerror
Download raw message
On 7/21/2022 6:38 PM, Jack Gleeson wrote:
>
>
>>> I'm not seeing where in this patch it is recognizing the ~~ notation.
> That's something built in to the mistletoe library.
> It also includes support for tables - also not in CommonMark.
> I'm just providing a function to render the existing strikethrough tokens
> as strikethroughs.
>
>

Understood, thank you.
Details
Message ID
<CLM12DP2ATCK.G4ZVMMUJW395@taiga>
In-Reply-To
<HN9EFR.1GFJIRNOF2BO2@jpgleeson.com> (view parent)
DKIM signature
pass
Download raw message
On Fri Jul 22, 2022 at 1:38 AM CEST, Jack Gleeson wrote:
> >> I'm not seeing where in this patch it is recognizing the ~~ notation.
>
> That's something built in to the mistletoe library. It also includes
> support for tables - also not in CommonMark. I'm just providing a
> function to render the existing strikethrough tokens
> as strikethroughs.

Ugh, that's annoying. The whole point of commonmark was to put a stop to
all of these private vendor extensions.
Details
Message ID
<CLM13CGLS7OX.JJIPCTMLR6I6@taiga>
In-Reply-To
<20220721021415.40062-1-jack@jpgleeson.com> (view parent)
DKIM signature
pass
Download raw message
Since we stick to CommonMark, I would prefer to see this implemented by
users with <del> tags rather than ~~. Can you update this patch to only
add del to the whitelist?
Details
Message ID
<b6bd2051-e63e-0fdd-31f6-f0e504776c48@c9yh.net>
In-Reply-To
<CLM12DP2ATCK.G4ZVMMUJW395@taiga> (view parent)
DKIM signature
permerror
Download raw message
On 7/22/2022 3:05 AM, Drew DeVault wrote:
> On Fri Jul 22, 2022 at 1:38 AM CEST, Jack Gleeson wrote:
>>>> I'm not seeing where in this patch it is recognizing the ~~ notation.
>> That's something built in to the mistletoe library. It also includes
>> support for tables - also not in CommonMark. I'm just providing a
>> function to render the existing strikethrough tokens
>> as strikethroughs.
> Ugh, that's annoying. The whole point of commonmark was to put a stop to
> all of these private vendor extensions.
So, to clarify, is this patch dead?
Details
Message ID
<CLMD85O66ATQ.1KP5F9U79SCC6@taiga>
In-Reply-To
<b6bd2051-e63e-0fdd-31f6-f0e504776c48@c9yh.net> (view parent)
DKIM signature
pass
Download raw message
On Fri Jul 22, 2022 at 7:34 PM CEST, Brett Gilio wrote:
> > Ugh, that's annoying. The whole point of commonmark was to put a stop to
> > all of these private vendor extensions.
> So, to clarify, is this patch dead?

No, I followed up on the patch asking for a different approach.
Reply to thread Export thread (mbox)