Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Allow Markdown in setting descriptions - #635

Merged
lee-dohm merged 5 commits into
masterfrom
ld-markdown-descriptions
Aug 19, 2015
Merged

lee-dohm merged 5 commits into
masterfrom
ld-markdown-descriptions

Conversation

@lee-dohm

Copy link
Copy Markdown
Contributor

Allows Markdown in setting descriptions, for example from my tabs-to-spaces package ...

Before:

screen shot 2015-08-17 at 7 46 26 pm

After:

screen shot 2015-08-17 at 7 47 13 pm

Fixes #618

@lee-dohm lee-dohm changed the title WIP: Allow Markdown in setting descriptions Allow Markdown in setting descriptions Aug 18, 2015
@lee-dohm

Copy link
Copy Markdown
Contributor Author

There aren't any other specs for the Space Pen helpers in settings-panel.coffee and I wasn't able to easily pull the requisite methods up into the SettingsPanel class, so I left out the specs. Let me know if I need to get some specs in place to get this merged.

In the meantime, I'll continue trying.

@thomasjo

Copy link
Copy Markdown
Contributor

We definitely need to whitelist markup features; supporting headers, images, lists, HTML, and so forth, is a bad idea. It will be misused/abused. Off the top of my head, the only markup we should support is

  • *italic*
  • **bold**
  • [link](http://atom.io)
  • code

Although, not having studied how marked's lexer tokenizes the input, using only content from the first <p>..</p> might alleviate most, if not all, of my concerns. I really think we need specs just because of this.

@lee-dohm

Copy link
Copy Markdown
Contributor Author

It looks like overriding the renderer might be a good method of whitelisting things:

https://www.npmjs.com/package/marked#overriding-renderer-methods

We can just have the elements that we don't want to support emit nothing. I think supporting all the inline methods except images and none of the block methods to begin with would be fine.

I'll extract the Markdown description stuff into a separate file to make it easy to spec. Then we can just call it from settings-panel.

@thomasjo

Copy link
Copy Markdown
Contributor

💥 Nice!

Whitelisted only the following Markdown constructs:

* **bold**
* *italic*
* `code spans`
* line breaks `<br/>`
* ~~strikethrough~~
* [links](http://www.example.com)

Added specs
Comment thread lib/rich-description.coffee Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a purely aesthetic viewpoint, it might look a bit more tidy if all of these were collapsed to single lines;

renderer.code = -> ''
renderer.blockquote = -> ''
renderer.heading = -> ''
renderer.html = -> ''
renderer.image = -> ''
renderer.list = -> ''

What do you think?

@thomasjo

Copy link
Copy Markdown
Contributor

Besides my 🎨 comment, I think this looks good 🚀

@jerone

jerone commented Aug 18, 2015

Copy link
Copy Markdown
Contributor

👍 Great pull.

I'm wondering if blacklisted markdown should be stripped or kept as normal text.

lee-dohm added a commit that referenced this pull request Aug 19, 2015
Allow Markdown in setting descriptions
@lee-dohm
lee-dohm merged commit 5a115f9 into master Aug 19, 2015
@lee-dohm
lee-dohm deleted the ld-markdown-descriptions branch August 19, 2015 00:46
@lee-dohm

Copy link
Copy Markdown
Contributor Author

@jerone I figured it was an easy first step to just strip it. If we find a use case where keeping it as normal text is really necessary (beyond "I didn't know that wasn't allowed") then we can add the complexity later.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants