notslang / tidy-markdown

Beautify Markdown, fixing formatting mistakes and standardizing syntax
https://npmjs.com/package/tidy-markdown
GNU General Public License v3.0
75 stars 11 forks source link

How can I personally DISABLE filter: 'img' from converters.coffee #55

Closed graphicsminded closed 6 years ago

graphicsminded commented 7 years ago

How can I personally DISABLE filter: 'img' from converters.coffee so my Atom doesn't smash my <img> tags when I hit save?

I'm sorry but I don't see a "How to Customize your tidy-markdown" section.

Your code in your converters.coffee

{
    filter: 'img'
    surroundingBlankLines: false
    replacement: (content, node, links) ->
      alt = getAttribute(node, 'alt') or ''
      url = getAttribute(node, 'src') or ''
      title = getAttribute(node, 'title')
      referenceLink = _.find(links, {url, title})
      if referenceLink
        if alt.toLowerCase() is referenceLink.name
          "![#{alt}]"
        else
          "![#{alt}][#{referenceLink.name}]"
      else if title
        "![#{alt}](#{url} \"#{title}\")"
      else
        "![#{alt}](#{url})"
  }

I just want to disable this somehow in Atom so I can commit <img> tags to my README.md file.

Can I disable just this this one filter or do I have to turn off tidy-markdown all together?

Thanks, Scott

notslang commented 7 years ago

Oh, it's supposed to be as non-customizable as possible. What do you want <img> tags for?

graphicsminded commented 7 years ago

Thanks for responding. I am using tags in the README.md so that I may set a style="max-width:200px;" inside the tag, otherwise the image looks like this.

When I want it to look like this.

Is there any way I can turn off just that one filter without having to completely disable tidy-markdown?

Thanks, Scott

notslang commented 7 years ago

Oh, we should just detect whether or not the tag has important attributes like width/height and disable it that way. Then we don't need any configuration and it does basically what anyone would expect - convert HTML to markdown, but not fundamentally change the structure of the document.