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

PR: Add Markdown syntax highlighter. #4352

Merged
merged 6 commits into from
Apr 19, 2017

Conversation

rlaverde
Copy link
Member

@rlaverde rlaverde commented Apr 11, 2017

As a part of the development of https://github.com/spyder-ide/spyder-reports is necessary to add markdown support to the editor

@rlaverde rlaverde added this to the v3.2 milestone Apr 11, 2017
@rlaverde rlaverde self-assigned this Apr 11, 2017
@rlaverde rlaverde requested a review from ccordoba12 April 11, 2017 13:35
@ccordoba12 ccordoba12 changed the base branch from master to 3.x April 11, 2017 14:50
@ccordoba12
Copy link
Member

Thanks a lot for this @rlaverde!! Could you post a screenshot of a Markdown file with code blocks? Thanks!

@rlaverde
Copy link
Member Author

rlaverde commented Apr 11, 2017

@ccordoba12
markdown sh

I think this is kinda ready,

Although I've run into an issue: there isn't and standard way (maybe an api) to extend BaseSH; different languages need different keys, and styles for that keys

i.e.:

  • python have: keyword, string, number, builtin, definition...
  • md have: titles, links, strike-through, italic, bold, code, lists...

I'd to do an workaround to add new keys-styles, but that's styles aren't fully configurable

cc @goanpeca

if key == "code":
# Change to code
self.setFormat(0, len(text), self.formats["code"])
self.setCurrentBlockState(self.CODE)
Copy link
Member

Choose a reason for hiding this comment

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

Could we use here the highlighter corresponding to the code language?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a nice idea, I'm not sure, I'll try to do it

Copy link
Member

Choose a reason for hiding this comment

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

@ccordoba12 its a nice idea indeed, but I think we should postpone that to 4.0 as it would probably require a better re-estructuring of syntax highlighters.

I think for what we need this is already a good step

Copy link
Member

Choose a reason for hiding this comment

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

No problem.

@ccordoba12
Copy link
Member

there isn't and standard way (maybe an api) to extend BaseSH

I think Markdown is a special case, so let's leave things as they are for now.


In your screenshot, the last line is not highlighted correctly: but is in green when it should be in black.

@rlaverde
Copy link
Member Author

I think Markdown is a special case

I don't think so, It'll happen with other markup languages (html, rest), or config files (ini, yaml), also with some frameworks (jinja), also with other programming languages that aren't python-like.

so let's leave things as they are for now.

yes, but maybe we could improve this for spyder4

In your screenshot, the last line is not highlighted correctly: but is in green when it should be in black.

Thanks, I didn't notice, I fixed the regex 😄

@ccordoba12
Copy link
Member

It'll happen with other markup languages (html, rest), or config files (ini, yaml), also with some frameworks (jinja)

We already have support for all those formats (except Jinja). But the main idea is that Markdown is a special case because there's no Pygments support for it.

yes, but maybe we could improve this for spyder4

Maybe for 4.1, for now let's focus on getting this merged ;-)


Please merge with 3.x to fix CircleCI, and then I'll merge.

@ccordoba12
Copy link
Member

ccordoba12 commented Apr 19, 2017

This is ready (and I haven't noticed it, sorry :-). Merging.

@ccordoba12 ccordoba12 merged commit bb1f3f5 into spyder-ide:3.x Apr 19, 2017
ccordoba12 added a commit that referenced this pull request Apr 19, 2017
@rlaverde rlaverde deleted the markdown-support branch April 19, 2017 22:52
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