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

Make it possible to supply a filename for highlighted code #445

wants to merge 1 commit into
base: master


None yet
2 participants
Copy link

atodorov commented Nov 26, 2015

This patch makes it possible to supply a filename (or any arbitrary string for that matter) after the shebang line and it will be added to the generated code block.

You can see it in action here (search for

I've inherited pygments.HtmlFormatter in order to get it working quickly but maybe we'd want this to go straight into pygments. Let me know how you want to proceed. The CSS that goes with this change is as follows:

.codehilite .filename {
    width: 100%;
    display: block;
    font-size: 15px;
    color: #333;
    background-color: #F2F8FA;
    border: solid #CCC 1px;
    border-bottom: none;
    text-align: center;

@atodorov atodorov force-pushed the atodorov:filename_codehilite branch from 7ba6d54 to 6d7045a Nov 26, 2015

@atodorov atodorov force-pushed the atodorov:filename_codehilite branch from 6d7045a to 8e41193 Nov 26, 2015

atodorov added a commit to atodorov/ that referenced this pull request Nov 26, 2015


This comment has been minimized.

Copy link

waylan commented Nov 27, 2015

Thank you for your contribution. However, I'm unsure about this. I never understood the desire to pull the code blocks in from external pages. Why not just include the code in the document? Regardless, what is clear is that if such a feature were to be added, it should be part of #334 (see this comment). And that won't happen until version 3.0 is released; when all extensions will be broken out of the main lib and maintained separately (see the roadmap). In fact, we are in a feature freeze until the 3.0 release anyway. Therefore, I am closing this at this time. Feel free to bring this up when the extension gets its own repo.

@waylan waylan closed this Nov 27, 2015


This comment has been minimized.

Copy link

atodorov commented Nov 29, 2015

Hi @waylan ,
I think you've misunderstood me. I'm not proposing a parameter which will cause codehilite to read the source from an external file on disk, although I can see some people having a use for it.

What I'm proposing is an additional text string, which can be used to indicate the file name (or anything really) being displayed. It's like a title for the code block.

Btw I'd prefer if you leave this issue open and I will take care of it once the extensions are broken out into a separate repository.

Just for reference, the Pygments part is here:


This comment has been minimized.

Copy link

waylan commented Nov 30, 2015

Oh you want a title. Completely missed that. Also missed the fact that this requires upstream support. Given the later, this is definitely a no. No need to open a new issue (or reopen this one) as #334 should provide a way to accept any arbitrary keyword which is accepted by Pygments. In other words, Markdown should no longer need to have each keyword hardcoded for it to work.

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