-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Directory structure highlighting #193
Comments
I actually just had a thought, this could also be expanded to do things like highlight names of different types of files (such as directories, as opposed to regular files). |
Hi there! I think this is not very useful as it is, but it could be turned into something very useful if you are willing to work more on it. For example, you could add icons for file types (with a CSS |
That is kind of what I was implying by my comment, that it could be expanded on to be more useful. As I said, I wrote threw this together because I am trying to implement directory listings like this in a project I'm working on; I will likely keep expanding on it as I work on my project, and I will keep you informed. |
A little more mature example, this adds classnames based on file extension, so you can highlight different types of files differently: Prism.languages.folders = {
// Highlight symbols used to denote folder structure
'punctuation': /^([-|+`\s]+)/gm,
// Highlight the individual file names
'keyword': /([a-zA-Z0-9._].+)/g
};
Prism.hooks.add('wrap', function(env) {
// Add classnames for file extensions
if (env.language === 'folders' && env.type === 'keyword') {
var parts = env.content.split('.');
while (parts.length > 1) {
parts.shift();
// Ex. 'foo.min.js' would become '<span class="token keyword ext-min-js ext-js">foo.min.js</span>'
env.classes.push('ext-' + parts.join('-'));
}
}
}); |
The thread is a year old, but I found it funny, so I followed kbjr's path and did this : https://github.com/Golmote/prism-treeview (I don't think this should be included in Prism, but it was fun to do) |
@Golmote That's neat. How do you generate the dir structure text? Does |
I think you may need to specify ASCII encoding to get the syntax ( |
@mAAdhaTTah Actually, I just followed the syntax given by kbjr in his first comment. ^^ But if there is something official, I'd be glad to add support for it. @uranusjr Sounds fun, I'll see what I can do. :) |
... nice ... :) |
(Edit) I saw that this is added already. You rock! 👍 |
Does your version require the |
Currently it requires the [dir] part to display the icon of a folder. Without it, the entry will be considered to be a file. This is needed to make the distinction between an empty folder and a file without known extension. As far as I can tell, |
Actually, the From the man page:
|
Seems good to me. Now it will identify directories based on the trailing slash. The other chars appended by |
You're right. |
is there any reason why it is not in core? i think it's a very common need to show file structures in code blocks |
Hi @muescha, |
I created a new syntax file for highlighting plain-text directory structure diagrams, like this:
It's extremely simple, just a single small regex to highlight commonly used symbols for this purpose:
Is this something you think others might want? I can give you a pull request very easily if you think so, I just wasn't sure if anyone other than me cares :p
The text was updated successfully, but these errors were encountered: