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

Add custom attributes to links #126

Closed
wants to merge 1 commit into from
Closed

Add custom attributes to links #126

wants to merge 1 commit into from

Conversation

tqc
Copy link

@tqc tqc commented Feb 25, 2013

This code adds custom attributes to links for things like making all links open in a new window

options.customAttributes = { "a": " target=\"_blank\""}; 

node test/index.js customAttributes

Links is the only place I need to do this at the moment (leaving the default link behaviour can cause all sorts of problems in a phonegap app) but it is designed to be easily extended if necessary.

I'd prefer not to need the space at the start of the custom string, but removing that requires either adding a lot more code or always adding a space and changing the expected result of 20 or so of the tests.

@lepture
Copy link
Contributor

lepture commented Mar 1, 2013

@tqc I am doing it another way. See my pull request #129

After this is merged, we can make the renderer more powerful, and add the inline level renderer.

@tqc
Copy link
Author

tqc commented Mar 2, 2013

@lepture I initially considered using custom render functions, but decided against it for two reasons:

  • Performance/complexity cost of replacing existing code with configurable function calls
  • Defining the functions is more than the single line config setting I was looking for, especially when working with multiple types of link.

@lepture
Copy link
Contributor

lepture commented Mar 2, 2013

@tqc

  • The performance is not a really problem. Yes, it is slower, I did the benchmark, it is about 20ms slower, but who cares! It is still far more fast than any other pure javascript parsers. If I need performance, I will use robotskirt.
  • Convenience vs customizable. I am still using robotskirt, not coz its performance, but the custom renderer feature. You can do what ever you want with custom renderer. It's really powerful.

I am dropping robotskirt, and switch to marked, coz it's hard for windows users to install robotskirt, and I need to distribute my software to windows users.

@chjj
Copy link
Member

chjj commented Mar 30, 2013

Performance/complexity cost of replacing existing code with configurable function calls

If we add this, next we're going to be making them callbacks so the attributes can be dynamic, which I'm sure someone will request. So we'll have function calls either way. I'm going to put this on hold. A renderer might be better.

@chjj chjj closed this Mar 30, 2013
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