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 automatic hyperlinks #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add automatic hyperlinks #1

wants to merge 8 commits into from

Conversation

anseljh
Copy link
Member

@anseljh anseljh commented Sep 26, 2015

Adding links to the HTML was way easier than the .DOCX, so I tacked it first.

@kemitchell
Copy link
Member

Thanks so much for this!

Linkifying HTML is a common enough general problem that I've actually been doing it with an external script:

// linkify.js
var linkify = require('html-linkify')
var input = require('fs').readFileSync('/dev/stdin').toString()
process.stdout.write(linkify(input, { escape: false }))

Then:

$ commonform render -f html < agreement.commonform | node linkify.js > agreement.html

Incidentally, linkify handles e-mail addresses. It's a nice, tight package.

Three questions in my mind:

  1. Might users of commonform-html ever not want linkification?
  2. If so, should the functionality go behind an options-argument flag?
  3. What's the case for leaving linkification out of commonform-html, and perhaps mentioning a package like linkify in README or other doc?

Again, thanks so much. I will have a think today or tomorrow. Would love to read your thoughts, too!

@anseljh
Copy link
Member Author

anseljh commented Sep 26, 2015

I can't think of a reason not to linkify HTML.

Maybe a better approach is to use that library as a post-processing step at the end of the HTML rendering.

@anseljh
Copy link
Member Author

anseljh commented Oct 7, 2015

I've squinted at this for a while, but don't yet understand why the test fails. 😠

Instead of:
<div class="article"><p>This is a great website: <a href="http://example.com/">http://example.com/</a></p></div>

it produces:
<div class="article"><p>This is a great website: <a href="<a href="http://example.com/">http://example.com/</a>"><a href="http://example.com/">http://example.com/</a></a></p></div>

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

Successfully merging this pull request may close these issues.

2 participants