Comments (20)
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.
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:
- Unknown tag with text inside
<span class="foo">bar</span>
which we'd want to pass through as is - 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.
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.
Will be part of the upcoming next release, thanks again for reporting!
from reverse_markdown.
@benbalter: How did you achieve passing through an unknown tag? I am facing the exact problem right now.
from reverse_markdown.
Coded around the problem by using Nokogiri to modify the HTML before passing to reverse_markdown.
I made them known tags.
from reverse_markdown.
@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.
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.
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.
I like that approach a lot. I might call it pass
or pass_through
or similar instead of dump
, but
from reverse_markdown.
Alrighty! I'll open that issue again and let you know when it's done - shouldn't take too long.
from reverse_markdown.
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.
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.
@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.
skip
instead of bypass?
from reverse_markdown.
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.
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.
from reverse_markdown.
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.
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)
- [Question] How to change \n by </br> ?
- Process footnotes
- Hyphen(-) issue HOT 9
- HTML string containing underscores gets escaped and shown in output markdown HOT 11
- tag_border option is being ignored. HOT 3
- Blockquote not correctly closed HOT 1
- Improper space parsing within codeblock HOT 2
- Raise on character encoding errors HOT 2
- no new line char in code inside <pre> tag HOT 1
- Links to ids don't produce Markdown links HOT 3
- Github tables without a header row HOT 3
- Slack flavored Markdown HOT 6
- Too much blankspace gets stripped HOT 1
- Unwanted new line characters within lists with paragraphs HOT 1
- Consider changing the license to something listed on Open Source Initiative list of approved licenses HOT 2
- Doesn't handle <br><br> within <strong></strong> HOT 1
- Incorrect markdown from adjacent strong tags with non-strong text after
- Incorrect markdown with non-breaking space before </i>
- Add option to convert HTML entities such as to space or unicode non-breaking space HOT 1
- Untidy tags produce invalid Markdown HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reverse_markdown.