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

Enable syntax highlighting for inline code #134

Closed
RyanGlScott opened this issue Jul 19, 2014 · 3 comments
Closed

Enable syntax highlighting for inline code #134

RyanGlScott opened this issue Jul 19, 2014 · 3 comments

Comments

@RyanGlScott
Copy link

Copying from this issue from github/markup:

Currently, you can syntax-highlight code blocks. For example,

main :: IO ()
main = putStrLn "Hello, World!"

renders as

main :: IO ()
main = putStrLn "Hello, World!"

However, you cannot do the same with inline code such as

main :: IO ()

or

main :: IO ()

both of which get rendered as main :: IO () (without syntax highlighting) when used inline. It would be nice to have something like

haskell main :: IO ()

that gives you inline syntax-highlighting (right now, that would render as haskell main :: IO ()).

As gjtorikian suggested on the other issue, this could conceivably be fixed by changing this line to match on code tags, as well as pre.

@simeonwillbanks
Copy link
Contributor

@gjtorikian brings up a valid concern.

I wonder what the performance implications would be.

Maybe we add a context option for tags to syntax highlight, and the default option is a pre tag?

Once one or many tags can be searched, benchmarks could be performed.

Thoughts?

@gjtorikian
Copy link
Owner

The more I think about this the harder it becomes. Linguist uses file extensions and text analysis to determine how to highlight a file. A few tokens might not be enough to determine how code should be colored. (This is all just a pessimistic guess, though.)

@jch
Copy link
Contributor

jch commented Jul 28, 2014

It's an interesting suggestion, but I'm going to say no to this feature.

When using multi-line fenced code blocks, the user can explicitly specify the language for us to highlight. For inline blocks, we'd have to guess what the language is. There will be lots of ambiguity if it's only a few tokens, and if an inline phrase is used, then it's likely to be short. This would increase the time to render, and give potential bad highlights.

@jch jch closed this as completed Jul 28, 2014
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

No branches or pull requests

4 participants