Git Product home page Git Product logo

Comments (20)

xijo avatar xijo commented on July 27, 2024

Hey Ben,

I agree, it would be nice to have an option for that. I'll dig into that and let you know, alright?

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

If you could point me in the right direction, would be glad to help. I get stuck on getting a tag back with its attributes as a string. Two cases to handle:

  1. Unknown tag with text inside <span class="foo">bar</span> which we'd want to pass through as is
  2. Unknown tag with known tag inside <span class="foo"><b>bar</b></span> which we'd want to be <span class="foo">**bar**</span>.

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

Coded around the problem by using Nokogiri to modify the HTML before passing to reverse_markdown. Closing since it's no longer an issue for me, but can reopen if you'd prefer.

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

Will be part of the upcoming next release, thanks again for reporting! 👍

from reverse_markdown.

mbrgm avatar mbrgm commented on July 27, 2024

@benbalter: How did you achieve passing through an unknown tag? I am facing the exact problem right now.

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

Coded around the problem by using Nokogiri to modify the HTML before passing to reverse_markdown.

I made them known tags.

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

@mbrgm I release 0.5.0 where ignore_unknown_tags = true is the default. Just upgrade to the new version should be enough though.

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

It seems the new default behavior in 0.5.0 is to pass the tags through as HTML (rather than dropping them as it did before). Turning off ignore_unknown_tags raises the error, preventing conversion. If I wanted it to ignore (rather than pass through) unknown tags, would a begin/rescue block be the best route?

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

Sure, catching ReverseMarkdown::UnknownTagError is valid option, although it might be tough to do it at the right spot.
Maybe a third option would be nice to do that, something like

config.unknown_tags = :raise  # Raises the error
config.unknown_tags = :drop   # Drops the these tags
config.unknown_tags = :dump   # Dumps tags as html 

What do you think?

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

I like that approach a lot. I might call it pass or pass_through or similar instead of dump, but 👍.

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

Alrighty! I'll open that issue again and let you know when it's done - shouldn't take too long.

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

There are 4 options now:

config.unknown_tags = :raise        # Raises the error
config.unknown_tags = :drop         # Drops the these tags
config.unknown_tags = :pass_through # Include the html
config.unknown_tags = :bypass       # Ignore tags but handle their children

from reverse_markdown.

mbrgm avatar mbrgm commented on July 27, 2024

I made them known tags.

Ah, ok.

@mbrgm I release 0.5.0 where ignore_unknown_tags = true is the default. Just upgrade to the new version should be enough though.

Unfortunately I need a ruby gem which does not yet support ~> 2.0.0, so I'll have to stick with 0.4.7 for some time.

Maybe a third option would be nice to do that, something like

config.unknown_tags = :raise  # Raises the error
config.unknown_tags = :drop   # Drops the these tags
config.unknown_tags = :dump   # Dumps tags as html ```

What do you think?

+1 on that, and +1 on :pass_through.

Edit: Few seconds too late ;-). I really like the changes. Great work!

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

@mbrgm I just added 1.9.3 support back in, hope this helps you.

Once travis ran through I'll release 0.5.1 with those changes. Thanks to both of you for participating, it's always more fun if one gets some feedback! 👍

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

❤️ that approach. 🚲-shedding, but perhaps skip instead of bypass?

from reverse_markdown.

mbrgm avatar mbrgm commented on July 27, 2024

Great @xijo. Thanks for adding 1.9.3 support! This gem saves me a ton of work converting HTML documentation to an easiier maintainable markdown version!

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024
There are only two hard things in Computer Science: cache invalidation and naming things.

Isn't it? :)

I chose bypass to ensure one understands that the content gets converted. skip could also mean that the whole tag is skipped, so no content conversion takes place, don't you think?

from reverse_markdown.

benbalter avatar benbalter commented on July 27, 2024

👍

from reverse_markdown.

mbrgm avatar mbrgm commented on July 27, 2024

I just came to the point where I'd want to keep the unknown tag but process its children, i.e. a mixture of :pass_through and :bypass. Do you think it would be feasible to add another option for this case?

from reverse_markdown.

xijo avatar xijo commented on July 27, 2024

Hmm, that would be the use for a custom converter I think. You can write and register them for your special needs, I wrote an wiki page about it: https://github.com/xijo/reverse_markdown/wiki/Write-your-own-converter

Please let me know if it worked out for you or if you had trouble with this approach.

from reverse_markdown.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.