question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Directory structure highlighting

See original GitHub issue

I created a new syntax file for highlighting plain-text directory structure diagrams, like this:

|-- app
|   |-- controllers
|   |-- models
|   `-- views

It’s extremely simple, just a single small regex to highlight commonly used symbols for this purpose:

Prism.languages.folders = {
    // Just highlight symbols used to denote folder structure
    keyword: /^([-|+`\s]+)/gm
};

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

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:19 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
kbjrcommented, Dec 21, 2013

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('-'));
        }
    }
});
0reactions
Golmotecommented, Apr 6, 2020

@LeaVerou He meant why is it an external project. But we now have included this feature as a plugin in #2265! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Creating Highlight Tree Structure
Creating Highlight Tree Structure. Overview. The Network Explorer comprises folders and locations. Folders may contain other folders and/or locations.
Read more >
Print Directory & File Structure with icons for representation in ...
I want a Linux command to print directory & file structures in the form of a tree, possibly with Unicode icons before each...
Read more >
File Structure : Broad Institute of MIT and Harvard
A successful file structure organizes your data and code with the goal of repeatability, ... When you double click on a segment of...
Read more >
How to display folder structure in markdown files - W3schools.io
This post talks about how to generate folder structure in markdown. Markdown is plain text content that is easy to read and converted...
Read more >
Directory Structure - Hugo
Hugo's CLI scaffolds a project directory structure and then takes that single directory and uses it as the input to create a complete...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found