Skip to content

Instantly share code, notes, and snippets.

@mhauri
Last active October 27, 2020 19:07
Show Gist options
  • Save mhauri/8a7d6dbcd101e362894d86d45ca2a0bc to your computer and use it in GitHub Desktop.
Save mhauri/8a7d6dbcd101e362894d86d45ca2a0bc to your computer and use it in GitHub Desktop.
Tree Extension for gatsby-remark-prismjs
// In your gatsby-config.js
plugins: [
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-prismjs`,
options: {
languageExtensions: [
{
language: "tree",
extend: "json",
definition: {
'entry-line': [
{
pattern: /\|-- |├── /,
alias: 'line-h'
},
{
pattern: /\| |│ /,
alias: 'line-v'
},
{
pattern: /`-- |└── /,
alias: 'line-v-last'
},
{
pattern: / {4}/,
alias: 'line-v-gap'
}
],
'entry-dir': {
pattern: /.*[\/](?!\w).*/,
inside: {
// symlink
'operator': / -> /,
}
},
'entry-symlink': {
pattern: /.*\S.* (-> .*)/,
inside: {
'operator': / -> /,
'file': /(.*)/,
}
},
'entry-name': {
pattern: /.*\S.*/,
inside: {
// symlink
'operator': / -> /,
}
},
},
},
]
}
},
],
}
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment