Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor sub elements and support for placeholders, fragments, and HTML4 name #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

benjaminma
Copy link
Contributor

Suggested anchor handling:

  • <a href="mailto:address"> - keep address
  • <a href="#fragment"> - process sub elements
  • <a href="url"> - keep url, process sub elements
  • <a name="id"> - process sub elements
  • <a> - process sub elements

@mlegenhausen
Copy link
Member

I agree with <a href="mailto:address">, <a name="id"> and <a>. <a href="#fragment"> depends on if you have links like "Jump to Foo" or not. The same applies to <a href="url">.

I think even for the mailto option other people want another behaviour. I think the best approuch would be to use your defaults and make them avaibale via options parameters. Something like this:

var text = htmlToText.fromString('<h1>Hello World</h1>', {
    format: {
        a: {
            mailTo: 'value' // 'append', 'prepend', 'inner' or supply a Function,
            url: 'append',
            fragment: 'inner',
            name: 'inner',
            none: 'inner'
         } // Replace this by a Function and handle all link types by your own
    }
});

These are the default options. I wrapped it in an format option so it is extensable (maybe for all tags in the future).

Following behaviour per value:

  • value - use the value inside the attribute
  • inner - process the child elements
  • append or prepend - put the link in brackets [] before or after the sub element text representation
  • Function - Add your own formatting behaviour.

What do you mean?

@otopsy otopsy mentioned this pull request Sep 16, 2013
@otopsy
Copy link

otopsy commented Sep 16, 2013

it will fix the "href missing bug" too !

@mlegenhausen
Copy link
Member

I currently don't have the time or the need to resolve this issue.
Push requests are welcome ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants