#8085 Add support for checkboxes to the markdown convertor

v1.9.0
closed
None
General
2018-09-24
2016-05-19
Rohan Verma
No

Checkboxes can be rendered from [ ] and [x]

It is useful for maintaining lists and TODOs

Related

Tickets: #8085
Tickets: #8230

Discussion

  • Hi

    I tried to work with this issue. This can be done but issue is ForgeLinkTreeProcessor's articat linking also converts [ ] to links. How we can solve the issue

     
    • Dave Brondsema

      Dave Brondsema - 2018-08-21

      Hi Shalitha,

      I haven't tried this myself, so I'm not sure what all the challenges will be exactly, but I looked into it a little bit right now. The ForgeLinkTreeProcessor code adds [ and ] around existing links like [SomeWikiPage], so shouldn't affect [ ] and only maybe [x] if there is a page called x. It could be customized to inspect the node properties & text more if needed to apply only in certain situations.

      It looks like there is an extension for markdown to implement the checkbox idea, might be good to try using that rather than writing something from scratch: https://github.com/FND/markdown-checklist

       
  • Hi Dave

    Yeah agree. I think we can use custom regex for markdown.inlinepatterns.SHORT_REF_RE
    I will give an update. Need to check how we can skip sanitize html part for

    Thanks

     
  • Hi..

    Now checklist is working but when sanitization is disabled

    I have added markdown checlist plugin to extensions
    extensions=['fenced_code', 'codehilite',
    ForgeExtension(
    **kwargs), 'tables', 'toc', 'nl2br', 'markdown_checklist.extension']
    ,

    Used custom short reference regex

        md.inlinePatterns['short_reference'] = ForgeLinkPattern(markdown.inlinepatterns.NOIMG + '\\[([^ x\\]]+)\\]', md, ext=self)
    

    This will skip [ ] and [x]

    But how we can deal with html sanitizer?

     
  • Update. All working well when we remove <input> element from sanitizer blacklist. Is it okay to allow input element to be rendered ?

        ns_html = html5lib.constants.namespaces['html']
        _form_elements = {(ns_html, 'button'),
                          (ns_html, 'datalist'),
                          (ns_html, 'fieldset'),
                          (ns_html, 'form'),
                          #(ns_html, 'input'),
                          (ns_html, 'label'),
                          (ns_html, 'legend'),
                          (ns_html, 'meter'),
                          (ns_html, 'optgroup'),
                          (ns_html, 'option'),
                          (ns_html, 'output'),
                          (ns_html, 'progress'),
                          (ns_html, 'select'),
                          (ns_html, 'textarea'),
                          }
        self.allowed_elements = set(html5lib.filters.sanitizer.allowed_elements) - _form_elements
    
     
    • Dave Brondsema

      Dave Brondsema - 2018-09-04

      Yes I think that would be ok if it is what's needed to make this feature work.

      The various form fields were removed because if people type <input... or <button> into a comment they probably want it to show the tag, not show an actual form element. So it was to reduce confusion. But it could be ok for this (we could also maybe fine-tune the type of input tag later)

       
      • Hi Dave

        Great.. I will be sending a merge request soon

        On Wed, 5 Sep 2018 1:02 am Dave Brondsema, dave@brondsema.net wrote:

        Yes I think that would be ok if it is what's needed to make this feature
        work.

        The various form fields were removed because if people type <input... or="" <button=""> into a comment they probably want it to show the tag, not show
        an actual form element. So it was to reduce confusion. But it could be ok
        for this (we could also maybe fine-tune the type of input tag later)


        Status: open
        Milestone: unreleased
        Created: Thu May 19, 2016 08:58 PM UTC by Rohan Verma
        Last Updated: Sun Sep 02, 2018 06:22 AM UTC
        Owner: Rohan Verma

        Checkboxes can be rendered from [ ] and [x]

        It is useful for maintaining lists and TODOs

        Sent from forge-allura.apache.org because you indicated interest in
        https://forge-allura.apache.org/p/allura/tickets/8085/

        To unsubscribe from further messages, please visit
        https://forge-allura.apache.org/auth/subscriptions/

         

        Related

        Tickets: #8085

  • Dave Brondsema

    Dave Brondsema - 2018-09-17
    • status: open --> closed
    • assigned_to: Rohan Verma --> Shalitha Suranga
    • Reviewer: Dave Brondsema
     
  • Dave Brondsema

    Dave Brondsema - 2018-09-24
    • Milestone: unreleased --> v1.9.0
     

Log in to post a comment.